文件分块上传 生成多个part文件 如何合并能 求大神指教

querystringcom querystringcom 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
private string WriteTempFile(HttpPostedFile uploadFile, int chunk)
{

string tempDir = FileHelper.GetTempPath();
if (!Directory.Exists(tempDir))
{
Directory.CreateDirectory(tempDir);
}
string fullName = string.Format("{0}\\{1}.part", tempDir, uploadFile.FileName);
if (chunk == 0)
{
//如果是第一个分块,则直接保存

uploadFile.SaveAs(fullName);
}
else
{
//如果是其他分块文件 ,则原来的分块文件,读取流,然后文件最后写入相应的字节
FileStream fs = new FileStream(fullName, FileMode.Append);
if (uploadFile.ContentLength > 0)
{
int FileLen = uploadFile.ContentLength;
byte[] input = new byte[FileLen];

// Initialize the stream.
System.IO.Stream MyStream = uploadFile.InputStream;

// Read the file into the byte array.
MyStream.Read(input, 0, FileLen);

fs.Write(input, 0, FileLen);
fs.Close();
}
}


return fullName;
}


上面的方法 把大文件分成4份

文件分成了4块
blob1461832382735.part
blob1461832382845.part
blob1461832384235.part
blob1461832385635.part

怎么合并?
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
querystringcom
C# 111,128 成员 642,536 内容