简体   繁体   English

访问路径 'c:\windows\system32\inetsrv\config\' 被拒绝

[英]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 帐户需要对该文件夹的读取权限(通常需要管理员权限)。

  • If you're running the program from Visual Studio, that's your account.如果你从 Visual Studio 运行程序,那是你的帐户。 Run VS as administrator and your code should work should work.以管理员身份运行 VS,您的代码应该可以正常工作。
  • If it's a web app, the app pool account needs read access to the folder.如果它是 Web 应用程序,则应用程序池帐户需要对该文件夹具有读取权限。
  • If it's a windows service, the host account needs access.如果它是 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.

相关问题 WebClient下载-“拒绝访问路径'c:\\\\ windows \\\\ system32 \\\\ inetsrv \\\\ MyPrintManager.exe'” - WebClient Download - “Access to the path 'c:\\windows\\system32\\inetsrv\\MyPrintManager.exe' is denied” 拒绝访问路径“ C:\\ Windows \\ System32 \\” - Access to the path 'C:\Windows\System32\ is denied 如何使用c#asp.net获取C:\\ Windows \\ System32 \\ inetsrv \\ config文件夹的访问控制 - How to get access control of C:\Windows\System32\inetsrv\config folder using c# asp.net GoogleWebAuthorizationBroker-拒绝访问路径'C:\\ Windows \\ system32 \\ config \\ systemprofile' - GoogleWebAuthorizationBroker - Access to the path 'C:\Windows\system32\config\systemprofile' is denied C#错误Windows启动时,对路径'C:\\ Windows \\ system32 \\ Com \\ dmp'的访问被拒绝 - C# Error Access to the path 'C:\Windows\system32\Com\dmp' is denied When Windows Startup ASP零:System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv \\ log4net.config' - ASP Zero :System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\log4net.config' EF6添加迁移失败-拒绝访问路径'C \\ WINDOWS \\ SYSTEM32 \\ MyContext.edmx' - EF6 add migration fails - Access to the path 'C\WINDOWS\SYSTEM32\MyContext.edmx' is denied 找不到文件 'c:\\windows\\system32\\inetsrv\\xxx.xlsx' - Could not find file 'c:\windows\system32\inetsrv\xxx.xlsx' 收到 DirectoryNotFoundException: c:\\windows\\system32\\inetsrv\\Static_Files 当应用程序移动到实时服务器时 - Received a DirectoryNotFoundException: c:\windows\system32\inetsrv\Static_Files When application was moved to a live server File.Move错误-System.IO.FileNotFoundException:找不到文件'c:\\ windows \\ system32 \\ inetsrv - File.Move Error - System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM