Delete a large number (>100K) of files with c# whilst maintaining performance in a web application?

前端 未结 10 2153
[愿得一人]
[愿得一人] 2020-12-30 04:40

I am trying to remove a large number of files from a location (by large I mean over 100000), whereby the action is initated from a web page. Obviously I cou

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 05:12

    Can you put all your files in the same directory?

    If so, why don't you just call Directory.Delete(string,bool) on the subdir you want to delete?

    If you've already got a list of file paths you want to get rid of, you might actually get better results by moving them to a temp dir then deleting them rather than deleting each file manually.

    Cheers, Florian

提交回复
热议问题