文件切割和合并的问题(多线程)
private void button3_Click(object sender, EventArgs e)
{
fromfile = this.textBox1.Text;
FileInfo f = new FileInfo(this.textBox1.Text);
int size = ((int)f.Length);
int num = Int32.Parse(this.comboBox1.SelectedItem.ToString());
step = size / num;
int position = 0;
Thread[] threads = new Thread[num];
for (int i = 0; i < num; i++)
{
if (i != num - 1)
{
threads[i] = new Thread(new ParameterizedThreadStart(this.SplitFile));
threads[i].Name = "part " + i;
threads[i].Start(position);
position += step;
}
}
FileStream fs = new FileStream(fromfile, FileMode.Open, FileAccess.Read);
fs.Position = (num - 1) * step ;
byte[] bytes = new byte[size - fs.Position];
fs.Read(bytes, 0, bytes.Length);
tofile = this.textBox2.Text + @ "\ " +