Home > Back-end >  C# XmlDocument.Load Issue
C# XmlDocument.Load Issue

Time:09-13

I plan to use XmlDocument.Load() when a user clicks on a file from an open window dialogue. I am testing it with a absolute path

XmlDocument.Load("C:\\filename.xml");

This errors out. Chrome Developer tools states it cannot find the file and it is looking for the file with the following form "/C:\filename.xml"

Obviously this won't work because for that preceding backslash. Is there a way to remove that or is there a better way to do what I am doing?

CodePudding user response:

EDIT : Like Alexander said, this is caused by specific access rights. Your code is good.

In case of, use @ for paths like that :

XmlDocument.Load(@"C:\filename.xml");

You won't be bothered by the number of \ especially if you use network paths like \\192.168.1.x\SharedFolder.

  • Related