string filePath = @"C:\Users\wangbinbin\Desktop\TestDemo\TestDemo\files\";
string savePath = (@"C:\Users\wangbinbin\Desktop\TestDemo\TestDemo\files\jayzai_{0}.rar", ("yyyyMMddHHmmssffff"));
using (FileStream fsRead = new FileStream(filePath, , ))
{
//文件总长度
long left = ;
//存储读取结果
byte[] bytes = new byte[1024];
//每次读取长度
int maxLength = ;
using (FileStream fsWrite = new FileStream(savePath, , ))
{
int start = 0;
int num = 0;
while (left > 0)
{
= start;
num = 0;
if (left < maxLength)
num = (bytes, 0, Convert.ToInt32(left));
else
num = (bytes, 0, maxLength);
if (num == 0)
break;
//保存文件
(bytes, 0, );
start += num;
left -= num;
}
}
}
List<FileStreamModel> list = new List<FileStreamModel>();
using (FileStream fsRead = new FileStream(filePath, , ))
{
//文件总长度
long left = ;
//存储读取结果
byte[] bytes = new byte[1024];
//每次读取长度
int maxLength = ;
int start = 0;
int num = 0;
while (left > 0)
{
= start;
num = 0;
if (left < maxLength)
num = (bytes, 0, Convert.ToInt32(left));
else
num = (bytes, 0, maxLength);
if (num == 0)
break;
(new FileStreamModel { offset = start, file = Convert.ToBase64String(bytes) });
start += num;
left -= num;
}
}
if (list != null && > 0)
{
using (FileStream fsWrite = new FileStream(savePath, , ))
{
foreach (var obj in list)
{
byte[] bytes = Convert.FromBase64String();
(bytes, 0, );
}
}
}
if (list != null && > 0)
{
using (FileStream fsWrite = new FileStream(savePath, , , ))
{
//OrderBy随机:打乱了分段顺序;自己测试玩的,可以去掉OrderBy
foreach (var obj in (o => ()))
{
byte[] bytes = Convert.FromBase64String();
(, );
(bytes, 0, );
}
}
}
if (list != null && > 0)
{
using (FileStream fsWrite = new FileStream(savePath, , , ))
{
//OrderBy随机:打乱了分段顺序;自己测试玩的,可以去掉OrderBy
var binaryWriter = new BinaryWriter(fsWrite);
foreach (var obj in (o => ()))
{
(, );
byte[] bytes = Convert.FromBase64String();
(bytes);//写入数据
}
();
}
}
public class FileStreamModel
{
public int offset { get; set; }
public string file { get; set; }
}