Click here to Skip to main content
15,077,641 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI
I have to read One XML File but I am facing lot of difficulties to read that

I have saved file in C drive.
When I take File path
C#
XmlReader xmlRdr = XmlReader.Create(@"C:\Form Data.xml");

It shows error ..." Could not find path ....
Please tell me How to solve this error

Regards
Rakesh
Posted
Updated 17-Feb-13 4:21am
v2

On Windows, you will need to double up the backslashes since that is the escape character. You need to change the syntax from:
C++
XmlReader xmlRdr = XmlReader.Create(@"C:\Form Data.xml");
to:
C++
XmlReader xmlRdr = XmlReader.Create(@"C:\\Form Data.xml");
   
Comments
Sandeep Mewara 17-Feb-13 10:22am
   
Are you sure? OP already have '@' at the start that should nullify the need of escape sequence.
Could not find path ....
To me the error simply says that the file does not exists on the path defined. Please make sure that the file is present in the location as defined.

Might me 'space' between the Form & Data words creating an issue OR you don't have the access priviledge to create a file at that location. Try at some other place.
C#
XmlReader xmlRdr = XmlReader.Create(@"C:\Form Data.xml");


Try:
C#
XmlReader xmlRdr = XmlReader.Create(@"D:\ChangedDrive\FormData.xml");
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900