Bizarre directory delete behaviour on SSD drive

前端 未结 6 830
遇见更好的自我
遇见更好的自我 2021-01-01 10:25

Directory c:\\test has 50 or so files in it, no subdirectories.

    If IO.Directory.Exists(\"C:\\test\") Then
        IO.Directory.Delete(\"C:\\test\", True)         


        
6条回答
  •  無奈伤痛
    2021-01-01 11:19

    After exploring System.IO.Directory with reflector, it looks like .Delete is just a wrapper around the FindFirstFile, FindNextFile, and RemoveDirectory Win API calls. There's nothing threaded or asynchronous about the .Net runtime's invokation of those API calls, or the API implementation themselves.

    Now, supposing its somehow a TRIM issue, you can disable TRIM by opening an elevated command prompt and using fsutil:

    fsutil behavior set disabledeletenotify 1
    

    To enable, run the same command with 0 as parameter.

    To query, use query as the command argument:

    fsutil behavior query disabledeletenotify 
    

提交回复
热议问题