“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------未能找到路径“D:\wwwroot\wangyiping\wwwroot\xmwater\image\1.jpg”的一部分。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“D:\wwwroot\wangyiping\wwwroot\xmwater\image\1.jpg”的一部分。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
[DirectoryNotFoundException: 未能找到路径“D:\wwwroot\wangyiping\wwwroot\xmwater\image\1.jpg”的一部分。]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +492
   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) +1038
   System.IO.FileStream..ctor(String path, FileMode mode) +64
   System.Web.HttpPostedFile.SaveAs(String filename) +87
   admin_lianjieadd.btnAdd_Click(Object sender, EventArgs e) +270
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
我上传图片的按钮 是这么写的:
    if (uploadFile.PostedFile.FileName != String.Empty)
        {
            
         uploadFile.PostedFile.SaveAs(Server.MapPath("/xmwater/image/" + System.IO.Path.GetFileName(uploadFile.PostedFile.FileName)));
            
        }在本地IIS 运行没错, 到服务器上就提示上面的错误了.

解决方案 »

  1.   

    去服务器上建个D:\wwwroot\wangyiping\wwwroot\xmwater\image文件夹
      

  2.   

     uploadFile.PostedFile.SaveAs(("/xmwater/image/"+System.IO.Path.GetFileName(uploadFile.PostedFile.FileName)); 
      

  3.   

    image文件夹 有了, 代码这么写:
    uploadFile.PostedFile.SaveAs(Server.MapPath("/xmwater/image/" + System.IO.Path.GetFileName(uploadFile.PostedFile.FileName))); D:\wwwroot\wangyiping\wwwroot\xmwater\image 与 D:\wwwroot\xmwater\image  有区别么?
                  
           
      

  4.   

    uploadFile.PostedFile.SaveAs((Server.MapPath("/xmwater/image/") + System.IO.Path.GetFileName(uploadFile.PostedFile.FileName)); 
      

  5.   

    uploadFile.PostedFile.SaveAs((Server.MapPath("/xmwater/image/") + System.IO.Path.GetFileName(uploadFile.PostedFile.FileName)); 
      

  6.   

     uploadFile.PostedFile.SaveAs(("/xmwater/image/"+System.IO.Path.GetFileName(uploadFile.PostedFile.FileName));    能保存到服务器下的  image 文件夹里么?