访问路径“XXX”;被拒绝
我制作了一个 Web 应用程序,并使用文件上传服务器控件
。当我将文件保存到特定文件夹时,我总是遇到此路径的访问被拒绝
,而且我还为Every One
授予了完全控制
权限。我在开发模式
下工作。我想要一个适用于开发模式
和生产环境的解决方案。
异常出现在以下行::
fu.SaveAs(Server.MapPath("~//xml"));
StackTrace:
StackTrace 位于 System.IO.__Error.WinIOError(Int32) 错误代码,字符串(可能是FullPath)\r\n
在 System.IO.FileStream.Init(字符串 路径、FileMode 模式、FileAccess 访问、Int32 权限、布尔值 useRights、FileShare 共享、Int32 bufferSize、FileOptions 选项、 SECURITY_ATTRIBUTES secAttrs,字符串 msgPath,布尔值 bFromProxy)\r\n at System.IO.FileStream..ctor(字符串 路径、FileMode 模式、FileAccess 访问、FileShare 共享、Int32 bufferSize、FileOptions 选项、 字符串 msgPath,布尔值 bFromProxy)\r\n 位于 System.IO.FileStream..ctor(字符串 路径,FileMode 模式)\r\n at System.Web.HttpPostedFile.SaveAs(字符串 文件名)\r\n 位于 System.Web.UI.WebControls.FileUpload.SaveAs(字符串 文件名)\r\n 位于 Schedule.ScheduleForm.btn_Search_Click(对象 发送者,ImageClickEventArgs e)
问题原因是 SaveAs()
方法,还是路径中有问题?因为我尝试了一切,我给了很多用户完全控制权限,但没有成功。
I make a web application and I use a File Upload server control
. When I save the files to a specific folder, I get Access denied
to this path all the time also I give Full control
permission for Every One
. I work in dev mode
. I want a solution for both the dev mode
and the production environment.
The exception appears in the following line::
fu.SaveAs(Server.MapPath("~//xml"));
StackTrace:
StackTrace " at
System.IO.__Error.WinIOError(Int32
errorCode, String maybeFullPath)\r\n
at System.IO.FileStream.Init(String
path, FileMode mode, FileAccess
access, Int32 rights, Boolean
useRights, FileShare share, Int32
bufferSize, FileOptions options,
SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)\r\n at
System.IO.FileStream..ctor(String
path, FileMode mode, FileAccess
access, FileShare share, Int32
bufferSize, FileOptions options,
String msgPath, Boolean
bFromProxy)\r\n at
System.IO.FileStream..ctor(String
path, FileMode mode)\r\n at
System.Web.HttpPostedFile.SaveAs(String
filename)\r\n at
System.Web.UI.WebControls.FileUpload.SaveAs(String
filename)\r\n at
Schedule.ScheduleForm.btn_Search_Click(Object
sender, ImageClickEventArgs e)
Is the SaveAs()
method the problem reason, or there is some thing wrong in the path? Because I tried everything, I gave full control permissions to many users, but in vain.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要授予对特定文件夹上的网络服务的写入权限。
You need to give write access to Network Service on the specific folder.
一个问题是您使用 IIS 来测试应用程序还是 VS 服务器中的构建?在第二种情况下,您需要向用户 ASP.NET 授予对该文件夹的权限。尝试一下看看是否有效
One question are you using IIS to test the app or the build in VS server?. In the second case you need to grant permission to the user ASP.NET to the folder. Try it and see if it works