1. 首页
  2. 编程语言
  3. C#
  4. c# 流断点上传

c# 流断点上传

上传者: 2021-05-10 22:17:21上传 RAR文件 206.42KB 热度 4次
大文件上传 断点上传 客户端 /// /// 服务器端地址,部署时为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(
下载地址
用户评论
码姐姐匿名网友 2025-03-10 17:27:25

这里主要是客户端的写法,我想找服务端怎么接受……可惜没有,不过这个代码还是挺不错的

码姐姐匿名网友 2025-03-10 08:42:22

资源还挺好的,就是积分太贵了。。。

码姐姐匿名网友 2025-03-10 12:44:22

好思维!非常nice