应用部署在64位win2003服务器上。iis运行在纯64位环境。代码中使用HttpPostedFile的SaveAs()方法向图片服务器上保存文件。程序上传jpg图片到服务器。执行到SaveAs()的时候,报一个异常:“系统无法打开文件”。问题是在另外一台服务器上成功创建一个0k大小的jpg文件。另外同样的应用还部署在其他2台服务器(都是32位的os)上。在这2台机器向图片服务器上保存文件都没有问题。

解决方案 »

  1.   

    调用栈:
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    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) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) 
    at System.IO.FileStream..ctor(String path, FileMode mode) 
    at System.Web.HttpPostedFile.SaveAs(String filename) 
    at Web.Pic.testUploadpic.btn_upload_Click(Object sender, EventArgs e) 
      

  2.   


    HttpPostedFile file = this.File1.PostedFile;
    filepath = Server.MapPath("a.jpg");
    file.SaveAs(filepath);
    使用上面的方法就可以保存到本机服务器上。
      

  3.   

    HttpPostedFile file = this.File1.PostedFile; 
    filepath = @"\\192.168.0.8\pic\a.jpg";
    file.SaveAs(filepath); 
    使用上面的方法就不可以保存到0.8上。 
      

  4.   

    HttpPostedFile file=Fileupload1.PostedFile;
    string filename=file.FileName;
    string path=server.MapPath("Files/")+filename;
    file.SaveAs(path);