我有一些代码来拆分文件并加入,现在我正在尝试制作一个从 url 拆分文件并下载的程序,例如http://tegos.ru/new/mp3_full/David_Guetta_feat_Ne-Yo_and_Akon_-_Play_Hard.mp3拆分此文件分两片下载
我的拆分器代码 Byte[] byteSource = System.IO.File.ReadAllBytes(FileInputpath); FileInfo fiSource = new FileInfo(txtPath.Text);
int partsize = (int)Math.Ceiling((double)(fiSource.Length / OutputFiles));
int fileOffset = 0;
string currPartPath;
FileStream fsPart;
int sizeReamining = (int)fiSource.Length;
for (int i = 0; i < OutputFiles; i++)
{
currPartPath = FolderOutputPath + "\\" + fiSource.Name + "." + String.Format(@"{0:D4}", i) + ".gparts";
if (!File.Exists(currPartPath))
{
fsPart = new FileStream(currPartPath, FileMode.CreateNew);
sizeReamining = (int)fiSource.Length - (i * partsize);
if (sizeReamining < partsize)
{
partsize = sizeReamining;
}
fsPart.Write(byteSource, fileOffset, partsize);
fsPart.Close();
fileOffset += partsize;
}
}