Faster file move method other than File.Move

前端 未结 3 2024
北恋
北恋 2021-02-09 02:39

I have a console application that is going to take about 625 days to complete. Unless there is a way to make it faster.

First off I am working in a directory that has a

3条回答
  •  我在风中等你
    2021-02-09 03:26

    It turns out switching from File.Move to setting up a FileInfo and using .MoveTo increased the speed significantly.

    It will run in about 35 days now as opposed to 625 days.

    FileInfo fileinfo = new FileInfo(Path.Combine(location, fileName));
    fileinfo.MoveTo(Path.Combine(rootDir, fileYear, fileMonth, fileName));
    

提交回复
热议问题