操作多线程向一个文件写数据
try
{
int ThreadIndex = Convert.ToInt32(threadIndex);
sw.Start();
FileStream fs = new FileStream(this.filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryReader br = new BinaryReader(fs);
FileStream nfs = new FileStream(this.NewFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
BinaryWriter bw = new BinaryWriter(nfs);
int ReadedLength;
byte[] buffer = new byte[EachFileSize[ThreadIndex]];
fs.Seek(FilePosition[ThreadIndex], SeekOrigin.Begin);
ReadedLength = br.Read(buffer, 0, EachFileSize[ThreadIndex]);
nfs.Seek(FilePosition[ThreadIndex], SeekOrigin.Begin);
bw.Write(buffer, 0, ReadedLength);
sw.Stop();
fs.Close();
nfs.Close();
br.Close();
bw.Close();
MessageBox.Show(ThreadIndex.ToString() + "done ");
}
catch (Exception ex)
{