我试图将源文件夹中的所有格式的文件(.txt、.pdf、.doc等)复制到目标文件夹。
我只写了文本文件的代码。
我应该怎么做才能复制所有格式的文件?
我的代码:
string fileName = "test.txt";
string sourcePath = @"E:\test222";
string targetPath = @"E:\TestFolder";
string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
string destFile = System.IO.Path.Combine(targetPath, fileName);
复制文件的代码:
System.IO.File.Copy(sourceFile, destFile, true);