const int SupportsCompression = 0x10;
const int SupportEncryption = 0x20000;
[DllImport("Kernel32.dll", SetLastError = true)]
extern static bool GetVolumeInformation(string vol, StringBuilder name, int nameSize, out uint serialNum,
out uint maxNameLen, out uint flags, StringBuilder fileSysName, int fileSysNameSize);
static void GetVolumeInfoDemo()
{
uint serialNum, maxNameLen, flags;
bool ok = GetVolumeInformation(@"C:\", null, 0, out serialNum, out maxNameLen, out flags, null, 0);
if(!ok)
{
throw new Win32Exception();
}
bool canCompress = (flags & SupportsCompression) != 0;
Console.WriteLine($"canCompress:{canCompress}");
bool canEncrypt = (flags & SupportEncryption) != 0;
Console.WriteLine($"canEncrypt:{canEncrypt}");
}