XmlDocument.Load() problem!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fengtso
    New Member
    • Jul 2008
    • 1

    XmlDocument.Load() problem!!!

    I've try to use the following command to load xml file.
    It works for Windows Application but doesn't work for Device Application.
    Please take a look the code and error message.Thanks a lot.

    doc = new XmlDocument();
    doc.Load("medic ationXML.xml");

    The error message is
    "FileNotFoundEx ception is unhandled"

    No matter I use relative path or direct path like "C:/xxx/xxx/aaa.xml"
    it just didn't work.

    I'm using VS 2005 and CF 2.0.Please help me solve the path problem.
    Thanks.
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    Hi there,

    This is a simple fix.... 1st you have to make sure that the xml document you are using is there on the device. If you are creating it in VS you must make sure it's properties (right click > properties) are "Copy if newer (or copy always)" and "Content" this way it will not be compiled yet will be copied to the output dir.

    Secondly, your file path isnt really valid. You might want to get a string representing the application dir.

    i.e. Applicaiton.Sta rtupPath.Getexe cutingAssembly etc (that isn't valid, but its something like that) then append " + @"/MyXMLDoc.xml" to it to point to your file.

    Hope that helps.

    Comment

    Working...