日期:2014-05-17 浏览次数:20543 次
string fileName = fuUploadFile.PostedFile.FileName; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); //加入调试代码发现问题出在这一行 WebClient myWebClient = new WebClient(); string uriString = Server.MapPath(@"./") + "uploadFiles" + System.IO.Path.GetFileName(fileName); BinaryReader br = new BinaryReader(fs); Byte[] postArray = br.ReadBytes(Convert.ToInt32(fs.Length)); Stream postStream = myWebClient.OpenWrite(uriString, "PUT"); if (postStream.CanWrite) { postStream.Write(postArray, 0, postArray.Length); } postStream.Close(); fs.Close();
[FileNotFoundException: 未能找到文件“E:\timer.txt”。] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +328 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, FileAccess access) +57 _Default.btnUploadFile_Click(Object sender, EventArgs e) +56 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