NTFSDirect is a .NET library that allows us to access and analyze the NTFS (NT File System) from an application written in C#.
What are the advantages of reading the NTFS file system directly? Mainly speed. We can obtain all the files in a directory much faster than with any other method.
NTFS is the file system used by Windows operating systems since Windows NT. It provides a robust set of features, including access control, compression, encryption, and error recovery.
The MFT is an essential part of NTFS, as it stores important metadata about all the files and directories on an NTFS volume. Each entry in the MFT represents a file or directory and contains information such as name, size, creation date, security attributes, and more.
NTFSDirect allows us to access the MFT directly to obtain information about the files and directories on an NTFS volume. The library is designed to provide developers with a very fast tool to obtain the internal structure of files and directories on an NTFS volume.
How to use NTFSDirect
We can easily add the library to a .NET project by downloading the project from Github and adding it to our solution.
Here is an example of how to use NTFSDirect extracted from the library’s documentation
string vol = "c:";
var fileList = new NTFSDirect.Enumerator(vol, new [] {".txt", ".md"});
foreach(string file in fileList)
{
FileInfo f = new FileInfo(file);
if (!f.Exists) { continue; } //every file is enumerated even ones we don't have access to.
}
In this case, we would find all the files in Volume C: that have the .txt
or .md
extension, and we would obtain the file information. The array of extensions is optional, and we could omit it to obtain all the files in the Volume.
NTFSDirect is Open Source, and all the code and documentation are available in the project’s repository on GitHub - NTFSDirect: NTFS MFT