我試圖從源文件夾複製所有格式文件(.txt,.pdf,.doc ...)文件到目的地。從c#中的文件夾複製所有類型的格式文件
我只寫文本文件的代碼。
我應該怎麼做才能複製所有格式文件?
我的代碼:
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);
可能的複製(http://stackoverflow.com/questions/677221/copy-folders-in-c-sharp-using-system-io) –