Supprimer un message
Altar
Ca marche Pour récupérer la taille & l'espace libre un petit exemple :
[DllImport("kernel32.dll")]
static extern bool GetVolumeNameForVolumeMountPoint(string lpszVolumeMountPoint, [Out] StringBuilder lpszVolumeName, uint cchBufferLength);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, out ulong lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);
StringBuilder sb = new StringBuilder(200);
GetVolumeNameForVolumeMountPoint("c:\\", sb, (uint)sb.Capacity);
ulong FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
GetDiskFreeSpaceEx(sb.ToString(), out FreeBytesAvailable, out TotalNumberOfBytes, out TotalNumberOfFreeBytes);
[DllImport("kernel32.dll")]
static extern bool GetVolumeNameForVolumeMountPoint(string lpszVolumeMountPoint, [Out] StringBuilder lpszVolumeName, uint cchBufferLength);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, out ulong lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);
StringBuilder sb = new StringBuilder(200);
GetVolumeNameForVolumeMountPoint("c:\\", sb, (uint)sb.Capacity);
ulong FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
GetDiskFreeSpaceEx(sb.ToString(), out FreeBytesAvailable, out TotalNumberOfBytes, out TotalNumberOfFreeBytes);