Search code examples
c#windowsdiskdefragmentation

Logic in Disk Defragmantation & Disk Check


What is the logic behind disk defragmentation and Disk Check in Windows? Can I do it using C# coding?


Solution

  • For completeness sake, here's a C# API wrapper for defragmentation:

    http://blogs.msdn.com/jeffrey_wall/archive/2004/09/13/229137.aspx

    Defragmentation with these APIs is (supposed to be) very safe nowadays. You shouldn't be able to corrupt the file system even if you wanted to.

    Commercial defragmentation programs use the same APIs.