FileNotFound when reading the IIS applicationHost.config file

时间:2016-07-11 21:21:28

标签: xml iis

Why I get FileNotFound using this code? if I move the applicationHost.config file to another directory such as c:\temp it will read just fine.

const string IIS_CONFIG_FILE = 
@"C:\Windows\System32\inetsrv\config\applicationHost.config";
string xml = File.ReadAllText(IIS_CONFIG_FILE);
XDocument doc = XDocument.Load(new StringReader(xml));

It has to do with the directory because I can't even open a simple Test.xml file there. I used Process Monitor from SysInternals but nothing is traced. Very weird.

Thank you Max

1 个答案:

答案 0 :(得分:0)

如果您尝试在32位应用程序中读取此类仅64位文件,则Windows会将您引导至等效的WOW64文件路径,该路径确实不存在。