public static long GetAvailableFreeBytes(string drive) { long ignored; long userBytes; if (!DllImports.GetDiskFreeSpaceEx(drive, out userBytes, out ignored, out ignored)) { throw new IOException("DriveName: " + drive + " ErrorCode:" + Marshal.GetLastWin32Error()); } return(userBytes); }
private static bool IsReady(string drive) { const int ERROR_NOT_READY = 0x00000015; long ignored; if (!DllImports.GetDiskFreeSpaceEx(drive, out ignored, out ignored, out ignored)) { return(Marshal.GetLastWin32Error() != ERROR_NOT_READY); } return(true); }