帮我看一下这代码
程序代码: Thread thd = null;
string thisPath = "";
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
thisPath = op.FileName;
thd = new Thread(new ThreadStart(th));
thd.Start();
}
}
private void th()
{
FileStream fs = new FileStream(thisPath, FileMode.Open, FileAccess.Read);
long length = fs.Length;
FileStream newfs = new FileStream("C:\\aa.rar", FileMode.Create, FileAccess.Write);
byte[] bytes = new byte[Convert.ToInt32(fs.Length)];
progressBar1.Maximum = 100;
progressBar1.Value = 0;
int post = 0;
long of = 0;
while (post < length)
{
int i = fs.Read(bytes, post, 1);
newfs.Write(bytes, post, 1);
if (post > 0)
{
of = fs.Length / post;
of = 100 - of + 1;
if (of > 0 )
{
progressBar1.Value = Convert.ToInt32(of);
}
}
post = post + 1;
}
newfs.Close();
newfs.Dispose();
fs.Close();
fs.Dispose();
MessageBox.Show("传输成功");
}这样的文件传输好吗?每次只发送1个字节
还有一个问题,执行时滚动条一开始走的很快,到最后就慢了,当到100%还要等上一会才提示MessageBox.Show("传输成功");这是为什么?











