我是windorm的程序,
string xmlFilePath = Directory.GetCurrentDirectory();
XmlDocument doc = new XmlDocument();
doc.Load(xmlFilePath);
然而在运行到doc.Load(xmlFilePath);的时候却提示:对路径“XXXX”的访问被拒绝。
我在网上了下,很多出问题的是webform的,而winform很少见到。
这个问题该怎么解决呢?
string xmlFilePath = Directory.GetCurrentDirectory();
XmlDocument doc = new XmlDocument();
doc.Load(xmlFilePath);
然而在运行到doc.Load(xmlFilePath);的时候却提示:对路径“XXXX”的访问被拒绝。
我在网上了下,很多出问题的是webform的,而winform很少见到。
这个问题该怎么解决呢?
方法得到的是文件夹路径
doc.Load()方法参数是文件的路径
以前这样用过,就是当前程序集当前目录
string assemblyFilePath = Assembly.GetExecutingAssembly().Location;
string assemblyDirPath = Path.GetDirectoryName(assemblyFilePath);
string configFilePath = assemblyDirPath + "\\log4net.config";
XmlDocument doc = new XmlDocument();
doc.Load(configFilePath); 你要确定路径对不对.权限对不对