How to fast delete many files

前端 未结 3 1449
梦如初夏
梦如初夏 2021-01-21 19:09

I have a folder in Windows Server with subfolders and ≈50000 files. When I click the right mouse button and choose delete (or shift+delete) – all files are deleted in 10-20 seco

3条回答
  •  不要未来只要你来
    2021-01-21 20:06

    Since the question is actually about deleting network shared folders and it's stated that the explorer based delete is much faster than the C# internal delete mechanism, it might help to just invoke a windows shell based delete.

    ProcessStartInfo Info = new ProcessStartInfo(); 
    Info.Arguments = "/C rd /s /q \"\""; 
    Info.WindowStyle = ProcessWindowStyle.Hidden; 
    Info.CreateNoWindow = true; 
    Info.FileName = "cmd.exe"; 
    Process.Start(Info);
    

    Ofcourse, you have to replace .

    However, I don't have the infrastructure and files available to test the performance myself right now.

提交回复
热议问题