c# 流断点上传
大文件上传 断点上传 客户端 /// /// 服务器端地址,部署时为Web端的地址,可以用配置文件实现 /// public static string serverPath; /// /// 上传文件(按照文件名称上传,支持断点) /// /// 待上传文件全路径 /// 上传时的流量控制,文件较大时,用于切割文件上传 /// 错误信息 /// 成功或者失败 public static bool UpLoadFile(string fileName, int byteCount,out string msg) { msg = ""; bool result = true; long cruuent = GetServerFileLength(fileName); FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader bReader = new BinaryReader(fStream); long length = fStream.Length; fileName = fileName.Substring(fileName.LastIndexOf('\\') + 1); #region 开始上传文件 try { #region 续传处理 byte[] data; if (cruuent > 0) { fStream.Seek(cruuent, SeekOrigin.Current); } #endregion #region 分割文件上传 for (; cruuent length) { data = new byte[Convert.ToInt64((length - cruuent))]; bReader.Read(data, 0, Convert.ToInt32((length - cruuent))); } else { data = new byte[byteCount]; bReader.Read(data, 0, byteCount); } try { Hashtable parms = new Hashtable(); parms.Add("fileName", fileName); parms.Add(
文件列表
DuanDanUploadTest.rar
(预估有个66文件)
DuanDanUploadTest
client
client.csproj
4KB
bin
Debug
client.pdb
30KB
client.vshost.exe.manifest
490B
client.exe
11KB
client.vshost.exe
11KB
Form1.Designer.cs
3KB
暂无评论