Exemple #1
0
        public static ulong  DiskFreeSpaceForUserDB(string workDir)
        {
            #region Preconditions
            if (workDir == null)
            {
                throw new ArgumentNullException("IOTools -- Input directory name is NULL");
            }
            #endregion Preconditions

            Win32Declarations.ULARGE_INTEGER userFree  = new Win32Declarations.ULARGE_INTEGER();
            Win32Declarations.ULARGE_INTEGER total     = new Win32Declarations.ULARGE_INTEGER();
            Win32Declarations.ULARGE_INTEGER totalFree = new Win32Declarations.ULARGE_INTEGER();
            bool rc = Win32Declarations.GetDiskFreeSpaceEx(Path.GetPathRoot(Path.GetFullPath(workDir)), ref userFree, ref total, ref totalFree);
            if (!rc)
            {
                throw new IOException("Failed to get disk free space");
            }
            return(userFree._value);
        }