简体   繁体   English

WebClient下载-“拒绝访问路径'c:\\\\ windows \\\\ system32 \\\\ inetsrv \\\\ MyPrintManager.exe'”

[英]WebClient Download - “Access to the path 'c:\\windows\\system32\\inetsrv\\MyPrintManager.exe' is denied”

I am attempting to download a file from another IIS site on my local machine. 我正在尝试从本地计算机上的另一个IIS站点下载文件。 I have my main website that is trying to download from another public site that contains a few files that the user will be able to download. 我的主要网站正在尝试从另一个包含一些文件的公共站点下载,用户可以下载这些文件。

[HttpGet]
public ActionResult DownloadMyPrintManagerInstaller()
{
    bool success;
    try
    {
        using (var client = new WebClient())
        {
            client.DownloadFile(new Uri("http://localhost:182//MyPrintInstaller.exe"), "MyPrintManager.exe");
        }
        success = true;
    }
    catch (Exception)
    {
        success = false;
    }

    return Json(new { Success = success }, JsonRequestBehavior.AllowGet);
}

For some reason, it is attempting to download the file from C:\\windows\\system32\\inetsrv\\MyPrintManager.exe ? 由于某些原因,它正尝试从C:\\windows\\system32\\inetsrv\\MyPrintManager.exe下载文件? Does anyone know how I can avoid it from pointing to that directory? 有谁知道如何避免它指向该目录? Do I need to modify my code or my IIS configuration? 我是否需要修改代码或IIS配置?

My virtual directory for this site is a folder sitting on my C: drive, and the file I actually want to download is in that directory. 我在该站点的虚拟目录是一个位于C:驱动器上的文件夹,而我实际要下载的文件在该目录中。

No, it's attempting to save the file to C:\\windows\\system32\\inetsrv\\MyPrintManager.exe . 不,它正在尝试将文件保存 C:\\windows\\system32\\inetsrv\\MyPrintManager.exe

That's because C:\\windows\\system32\\inetsrv is the working directory for your process, and you've just given a relative filename. 这是因为C:\\windows\\system32\\inetsrv是您的进程的工作目录,并且您刚刚指定了相对文件名。

Specify an absolute filename which says exactly where you want the file to be stored, and it should be fine. 指定一个绝对的文件名,该文件名将准确说明要存储文件的位置,应该没问题。

WebClient web = new WebClient();
string url = "http://.../FILENAME.jpg";
web.DownloadFile(new Uri(url), "C:/FILENAME.jpg");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 访问路径 'c:\windows\system32\inetsrv\config\' 被拒绝 - Access to the path 'c:\windows\system32\inetsrv\config\' is denied 拒绝访问路径“ C:\\ Windows \\ System32 \\” - Access to the path 'C:\Windows\System32\ 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 如何使用c#asp.net获取C:\\ Windows \\ System32 \\ inetsrv \\ config文件夹的访问控制 - How to get access control of C:\Windows\System32\inetsrv\config folder using c# asp.net EF6添加迁移失败-拒绝访问路径'C \\ WINDOWS \\ SYSTEM32 \\ MyContext.edmx' - EF6 add migration fails - Access to the path 'C\WINDOWS\SYSTEM32\MyContext.edmx' is denied GoogleWebAuthorizationBroker-拒绝访问路径'C:\\ Windows \\ system32 \\ config \\ systemprofile' - GoogleWebAuthorizationBroker - Access to the path 'C:\Windows\system32\config\systemprofile' 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 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' “访问路径'D:\\\\ Windows \\\\ system32 \\\\文件被拒绝”Azure Web App - “Access to the path 'D:\\Windows\\system32\\file is denied” Azure Web App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM