File copy using robo copy and process

前端 未结 5 1695
情歌与酒
情歌与酒 2021-02-19 23:30

I am creating a File copy program which will copy large number of files(~100,000) with size ~50 KB using ROBOCOPY command.

For each file, I am creating a new process an

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 00:09

    I would just use System.IO. Should be plenty fast enough, and your filename could be a wildcard.

    using System.IO;
    // snip your code... providing fileName, sourceDir, destinationDir
    DirectoryInfo dirInfo = new DirectoryInfo(sourceDir);
    FileInfo[] fileInfos = dirInfo.GetFiles(fileName);
    foreach (FileInfo file in fileInfos)
    {
        File.Copy(file.FullName, Path.Combine(destinationDir, file.Name), true);  // overwrites existing
    }
    

提交回复
热议问题