简体   繁体   中英

UnauthorizedAccessException: Access to path denied

When attempting to load an xml document for parsing, I continuously get the following error:

    An exception of type 'System.UnauthorizedAccessException' occurred in System.Private.Xml.dll but was not handled in user code
    Access to the path 'C:\Users\Delan\Code\Questions.xml' is denied.

This is a file, not a directory. The file is not read-only. It has full system access. I am running VS Code in administrator mode. I have moved the file around into several other directories, even creating new ones. I cannot see what is wrong with my code to be getting this error. After hours of searching, it seems the above solutions have worked for others, but they are not working for me. Any help or nudge in the right direction would be appreciated.

Code I have saved currently:

    XmlDocument doc = new XmlDocument();
    string path = @"C:\\Users\\Delan\\Code\\Questions.xml";
    doc.Load(path); // This is what causes the error

我是管理员,但是您确定您的应用程序以admin身份运行,还是使用其他组/用户?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM