Asp.net mvc 在ASP.NET MVC中,对路径的访问被拒绝
我试图使用以下代码创建目录:Asp.net mvc 在ASP.NET MVC中,对路径的访问被拒绝,asp.net-mvc,iis-7,virtual-directory,Asp.net Mvc,Iis 7,Virtual Directory,我试图使用以下代码创建目录: Directory.CreateDirectory("localhost/attachments/7075"); 但它返回了“对路径'localhost/attachments/7075'的访问被拒绝”。 请注意,附件来自网络共享文件夹。我使用IIS上的addvirtualdirectory添加了它 我所做的是: 尝试在共享文件夹中手动创建文件夹,我可以 我试图检查IIS\u IUsers文件夹中的证券,它处于完全控制状态 您需要使用Server.MapPath
Directory.CreateDirectory("localhost/attachments/7075");
但它返回了“对路径'localhost/attachments/7075'的访问被拒绝”。
请注意,附件
来自网络共享文件夹。我使用IIS上的addvirtualdirectory
添加了它
我所做的是:
- 尝试在共享文件夹中手动创建文件夹,我可以
- 我试图检查
文件夹中的证券,它处于IIS\u IUsers
完全控制状态
Server.MapPath()
来使用与虚拟路径对应的物理文件路径
Directory.CreateDirectory(Path.Combine(Server.MapPath("~/attachments"), "7075"));
您需要使用
Server.MapPath()
来使用与虚拟路径对应的物理文件路径
Directory.CreateDirectory(Path.Combine(Server.MapPath("~/attachments"), "7075"));