Error while loading string to xml document in windows c# -


i have application reads xml data, makes changes , saves word document. when run app 1st time base uri "c:\documents\visual studio 2010\projects\windowsformsapplication1\windowsformsapplication1\bin\debug". when run second time without restarting app base uri changes last saved location ans error saying xml file not found.below part of code. gng wrong

 string xmlsource = string.empty;              if (string.isnullorempty(xmlsource))                  xmlsource = "dictionary.xml";                  xmldocument doc = new xmldocument();                 doc.load(xmlsource);                 filestream usrfs = null;             try             {                  usrfs = new filestream(xmlsource, filemode.open, fileaccess.read,                                  fileshare.readwrite);              }              catch (ioexception ex)             {                 messagebox.show(ex.message);             }             try             {                  doc.load(usrfs);              }             catch (exception ex)             {                  messagebox.show(ex.message);             } 

use full path rather relative path.

xmlsource = system.appdomain.currentdomain.basedirectory + "\\dictionary.xml"; 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -