WebClient下载 - “访问路径”c:\\windows\\\system32\\inetsrv\\MyPrintManager.exe被拒绝“ [英] WebClient Download - "Access to the path 'c:\\windows\\system32\\inetsrv\\MyPrintManager.exe' is denied"
问题描述
我正在尝试从本地机器上的另一个IIS站点下载文件。我有我的主要网站,试图从另一个公共网站下载,其中包含用户可以下载的几个文件。
I am attempting to download a file from another IIS site on my local machine. 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);
}
由于某种原因,它尝试从 C:\windows\system32\inetsrv\MyPrintManager.exe
?有人知道我如何避免指向该目录?我需要修改我的代码或我的IIS配置吗?
For some reason, it is attempting to download the file from 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?
我的这个站点的虚拟目录是一个坐在我的C:驱动器上的文件夹,我实际想要的文件
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:\windows\system32\inetsrv\MyPrintManager.exe
。
这是因为 C:\windows\system32\inetsrv
是您的进程的工作目录,您刚刚给出了相对的文件名。
That's because C:\windows\system32\inetsrv
is the working directory for your process, and you've just given a relative filename.
指定一个绝对的文件名,它确切地说明要存储文件的位置,这应该是正常的。
Specify an absolute filename which says exactly where you want the file to be stored, and it should be fine.
这篇关于WebClient下载 - “访问路径”c:\\windows\\\system32\\inetsrv\\MyPrintManager.exe被拒绝“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!