How do I determine the degree in which a file is fragmented?
You can use the DeviceIoControl
function with the FSCTL_GET_RETRIEVAL_POINTERS
control code.
The FSCTL_GET_RETRIEVAL_POINTERS operation retrieves a variably sized data structure that describes the allocation and location on disk of a specific file. The structure describes the mapping between virtual cluster numbers (VCN offsets within the file or stream space) and logical cluster numbers (LCN offsets within the volume space).