【发布时间】:2009-07-21 08:06:07
【问题描述】:
我无法使用 FileUpload.SaveAs() 或 File.WriteAllText() 在我的网络服务器上保存文件。我保存的文件夹是 CHMOD 666。
我的代码是这样的:
File.WriteAllText(MapPath(".") + "\\Ads\\test.jpg", "test");
此代码在 Dev 中完美运行。服务器。
最好的问候, 拉塞·埃斯佩霍尔特
System.UnauthorizedAccessException:对路径 *' 的访问被拒绝。 在 System.IO.__Error.WinIOError(Int32 错误代码,字符串可能全路径) 在 System.IO.FileStream.Init(字符串路径、FileMode 模式、FileAccess 访问、Int32 权限、Boolean useRights、FileShare 共享、Int32 bufferSize、FileOptions 选项、SECURITY_ATTRIBUTES secAttrs、String msgPath、Boolean bFromProxy) 在 System.IO.FileStream..ctor(字符串路径,FileMode 模式,FileAccess 访问,FileShare 共享,Int32 bufferSize,FileOptions 选项,字符串 msgPath,布尔 bFromProxy) 在 System.IO.FileStream..ctor(字符串路径,FileMode 模式) 在 System.Web.HttpPostedFile.SaveAs(字符串文件名) 在 System.Web.UI.WebControls.FileUpload.SaveAs(字符串文件名) 在 *(Object sender, ListViewInsertEventArgs e)
【问题讨论】:
-
对路径 *' 的访问被拒绝 - 这是实际错误还是您从异常中删除了路径?
标签: c# asp.net file webserver mappath