访问路径(在 Web 应用程序下)被拒绝
Access to the path (under web application) is denied
为了简化问题:
我在 serverABC
(\serverABC\Equipment*
)
上部署了一个名为 Equipment
的 Web 应用程序
用户将通过函数\serverABC\Equipment\Folder1\...\File1.xls
复制一个文件到应用\serverABC\Equipment\Folder1\...\File1.xls
的源路径下:
System.IO.File.Copy ( strSourceFile, strDestFile, true );
strSourceFile ="\\serverABC\Equipment\Folder1\...\File1.xls"
在文件夹\serverABC\Equipment\Folder1
的properties -> Security
中,我给Network Service分配了读写权限,也就是web应用的应用池标识.
然后我在使用网络时遇到了这个错误:
Access to the path '\serverABC\Equipment\Folder1...\File1.xls' is denied.
不知道怎么回事
您不需要使用服务器名称,因为它在同一台服务器中。
因为您想保存到应用程序中的目录,请使用:
string path = Server.MapPath("Folder1");
然后将其与您的文件名连接起来并在 System.IO.File.Copy
.
中使用
为了简化问题:
我在 serverABC
(\serverABC\Equipment*
)
Equipment
的 Web 应用程序
用户将通过函数\serverABC\Equipment\Folder1\...\File1.xls
复制一个文件到应用\serverABC\Equipment\Folder1\...\File1.xls
的源路径下:
System.IO.File.Copy ( strSourceFile, strDestFile, true );
strSourceFile ="\\serverABC\Equipment\Folder1\...\File1.xls"
在文件夹\serverABC\Equipment\Folder1
的properties -> Security
中,我给Network Service分配了读写权限,也就是web应用的应用池标识.
然后我在使用网络时遇到了这个错误:
Access to the path '\serverABC\Equipment\Folder1...\File1.xls' is denied.
不知道怎么回事
您不需要使用服务器名称,因为它在同一台服务器中。
因为您想保存到应用程序中的目录,请使用:
string path = Server.MapPath("Folder1");
然后将其与您的文件名连接起来并在 System.IO.File.Copy
.