Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

XmlDocument.Load() problem!!!

Question posted by: fengtso (Newbie) on July 10th, 2008 09:54 PM
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("medicationXML.xml");

The error message is
"FileNotFoundException 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's Avatar
markmcgookin
Moderator
409 Posts
July 13th, 2008
04:32 PM
#2

Re: XmlDocument.Load() problem!!!
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.StartupPath.GetexecutingAssembly etc (that isn't valid, but its something like that) then append " + @"/MyXMLDoc.xml" to it to point to your file.

Hope that helps.

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,282 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top XML Forum Contributors