Stream rs; public bool Upload(FileInfo localFile, string remoteFileName) { try { bool result = false; if (localFile.Exists)//判定 { string url = Host.TrimEnd('/') + RemotePath + remoteFileName; FtpWebRequest request = CreateRequest(url, WebRequestMethods.Ftp.UploadFile); //上传数据 Stream rs = request.GetRequestStream(); using (FileStream fs = localFile.OpenRead()) { byte[] buffer = new byte[4096];//4K int count = fs.Read(buffer, 0, buffer.Length); while (count > 0) { rs.Write(buffer, 0, count); count = fs.Read(buffer, 0, buffer.Length); } fs.Close(); result = true; } return result; } } catch (Exception ex) { } throw new Exception(string.Format("本地文件不存在,文件路径:{0}", localFile.FullName)); } #endregion
上传大文件的时候出问题,请问应该怎么改
用第三方 控件。或者 自己写一个。