我有一个if语句,用于检查目录是否存在,以及它是否将该文件夹复制到指定位置。使用数组复制文件的进度条C#
整个复制过程位于预先确定的文件夹位置阵列上,for循环遍历阵列并在每个位置复制文件夹及其数据。
目前有200个不同的地点复制,还有更多的地方需要添加。
我想实现一个围绕这200个以上文件夹的复制进度条,但仍然运行到错误,我认为我遇到的问题主要是由于数组,我看过的教程(哪些不同相互之间很大)只涉及基本的文件复制。
如何让一个进度条工作的任何帮助或建议将不胜感激:)
for (int i = 0; i < pathArray.Length; i++)
{
string sourcePath = pathArray[i];
//MISSING CODE
if (System.IO.Directory.Exists(sourcePath))
{
System.IO.Directory.CreateDirectory(targetPathProper);
foreach (string dirPath in System.IO.Directory.GetDirectories(sourcePath,"*",
(System.IO.SearchOption.AllDirectories)))
{
System.IO.Directory.CreateDirectory(dirPath.Replace(sourcePath,
targetPathProper));
}
foreach (string newPath in System.IO.Directory.GetFiles(sourcePath, "*",
(System.IO.SearchOption.AllDirectories)))
{
System.IO.File.Copy(newPath, newPath.Replace(sourcePath,
targetPathProper), true);
}
} //end if
} // end for
什么样的错误?请更具体一些。您的问题与错误有关吗?或者它是如何实施进度条的? – ja72 2012-02-16 16:18:08
我的问题是如何实现它对不起:P现在我只是在backgroundWorker上阅读:P – cheeseman 2012-02-16 16:54:13
下载vXCopy(C#2.0)的源代码并从实现中学习。更好的是,按原样使用它。 http://vxcopy.codeplex.com/ – ja72 2012-02-16 16:19:53