当前位置: 代码迷 >> VB Dotnet >> 做的网站传照片找不到路径解决办法
  详细解决方案

做的网站传照片找不到路径解决办法

热度:108   发布时间:2016-04-25 02:19:27.0
做的网站传照片找不到路径
“/SheTuanWeb”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未能找到路径“D:\新社团\SheTuanWeb\files\2014\5\28125508.jpg”的一部分。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“D:\新社团\SheTuanWeb\files\2014\5\28125508.jpg”的一部分。

源错误: 


行 43:                 string ty = File2.PostedFile.ContentType;
行 44:               
行 45:                     File2.PostedFile.SaveAs(System.Web.HttpContext.Current.Server.MapPath(Pa) + ss);
行 46:                     s = ss;
行 47:                     return "3";
 

源文件: d:\新社团\SheTuanWeb\App_Code\upload.cs    行: 45 

堆栈跟踪: 


[DirectoryNotFoundException: 未能找到路径“D:\新社团\SheTuanWeb\files\2014\5\28125508.jpg”的一部分。]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +193
   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) +1162
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +61
   System.IO.FileStream..ctor(String path, FileMode mode) +55
   System.Web.HttpPostedFile.SaveAs(String filename) +95
   upload.Up(HtmlInputFile File2, String Pa) in d:\新社团\SheTuanWeb\App_Code\upload.cs:45
   UserReg.Button3_Click(Object sender, EventArgs e) in d:\新社团\SheTuanWeb\GeRen\UserReg.aspx.cs:84
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +107
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3436

 


--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.5448; ASP.NET 版本:2.0.50727.5456 
------解决方案--------------------
看看存在D:\新社团\SheTuanWeb\files\2014\5\这个路径不。
SaveAs方法好像是只能保存文件,无法创建目录。
在保存之前最好检查一下目录是否存在。
------解决方案--------------------
2楼说得没错,你保存的文件夹不存在,所以提示这样的错误。
  相关解决方案