哪位好心的大哥帮我解决一下多线程文件操作的问题,附代码。(2)
还是上午的那个问题,后来变了一下不行了。但那个问题已经结帖了,所以重发一贴请教。本人初学C#,比较菜,往高手多多指点:
上个问题就不贴了,地址在http://community.csdn.net/Expert/TopicView3.asp?id=5633807
现在改成:
private void bnCopyFilesSecret_Click(object sender, EventArgs e)
{
DialogResult drResult = fbdOpenFolder.ShowDialog();
if (drResult == DialogResult.OK)
{
foreach (DataGridViewRow dgvSelectedRow in dgvSecretResults.SelectedRows)
{
alArrayPath.Add(dgvSelectedRow.Cells[2].Value);
alArrayName.Add(dgvSelectedRow.Cells[1].Value);
}
Thread tdThread = new Thread(new ThreadStart(fnCopyFiles));
tdThread.ApartmentState = ApartmentState.STA;
tdThread.Start();
}
}
private void fnCopyFiles()
{
CFileOperation.fnCopyFiles(alArrayPath, alArrayName,fbdOpenFolder.SelectedPath,lbProcessInfoSecret);
}
将下面那些代码封装成了一个CFileOperate类,结构如下:
public void fnCopyFiles(ArrayList alPath, ArrayList alName, string szDestinationPath, Label lbLabelProcessShow)
{
for (int i = 0; i < alPath.Count; i++)
{
if (alPath[i] != null)
{