[英]Access to the path 'c:\windows\system32\inetsrv\config\' is denied
if (Fubrowse.HasFile)
{
string path = Path.GetFullPath(Fubrowse.PostedFile.FileName);
//string root = Path.GetPathRoot(path);
GetFilesFromDirectory(path.Substring(0, path.LastIndexOf("\\")));
}
else
GeneralClass.ShowMessageBox("Please Select File First.");
}
private void GetFilesFromDirectory(string DirPath)
{
try
{
DirectoryInfo Dir = new DirectoryInfo(DirPath);
FileInfo[] FileList = Dir.GetFiles("*.cs", SearchOption.AllDirectories);
foreach (FileInfo FI in FileList)
Here, path is c:\windows\system32\inetsrv\config\
.在这里,路径是c:\windows\system32\inetsrv\config\
。 I want to get all sub directories's file name in FileList
array.我想在FileList
数组中获取所有子目录的文件名。
The Windows account that's running your code needs read access to the folder (that typically requires admin rights).运行您的代码的 Windows 帐户需要对该文件夹的读取权限(通常需要管理员权限)。
I had the same issue.我遇到过同样的问题。 I couldn't get files from the C:\Windows\system32\intesrv\config
because my system was 64 bit and my request redirect to C:\Windows\SysWOW64\system32\intesrv\config
More explanation is given by this answer .我无法从C:\Windows\system32\intesrv\config
获取文件,因为我的系统是 64 位,并且我的请求重定向到C:\Windows\SysWOW64\system32\intesrv\config
这个答案给出了更多解释。
PS. PS。 My answer is left here just for those who will be in search in future我的答案留在这里,只为那些将要在未来寻找的人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.