哪位好心的大哥帮我解决一下多线程文件操作的问题,附代码。
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()
{
fnCopyFilesExe(alArrayPath, alArrayName);
}
public void fnCopyFilesExe(ArrayList alPath, ArrayList alName)
{
MessageBox.Show(Convert.ToString(alPath.Count-1));
for (int i = 0; i < alPath.Count-1; i++)
{
if (File.Exists(alPath[i].ToString().Remove(0, 5)))
{
try
&nb