Beispiel #1
0
        public static bool GetDiskFreeSpace(string rootPathName, out DiskSpace diskSpaceOut)
        {
            bool bResult;
            uint SectorsPerCluster;
            uint BytesPerSector;
            uint NumberOfFreeClusters;
            uint TotalNumberOfClusters;

            diskSpaceOut = new DiskSpace();
            bResult      = ApiNativeMethods.GetDiskFreeSpace(rootPathName,
                                                             out SectorsPerCluster, out BytesPerSector,
                                                             out NumberOfFreeClusters, out TotalNumberOfClusters);

            diskSpaceOut.SectorsPerCluster     = SectorsPerCluster;
            diskSpaceOut.BytesPerSector        = BytesPerSector;
            diskSpaceOut.NumberOfFreeClusters  = NumberOfFreeClusters;
            diskSpaceOut.TotalNumberOfClusters = TotalNumberOfClusters;
            diskSpaceOut.FreeBytes             = (long)(NumberOfFreeClusters) * (long)(SectorsPerCluster) * (long)(BytesPerSector);
            diskSpaceOut.TotalBytes            = (long)(TotalNumberOfClusters) * (long)(SectorsPerCluster) * (long)(BytesPerSector);
            return(bResult);
        }
Beispiel #2
0
		public static bool GetDiskFreeSpace (string rootPathName, out DiskSpace diskSpaceOut)
		{
			bool bResult;
			uint SectorsPerCluster;
			uint BytesPerSector;
			uint NumberOfFreeClusters;
			uint TotalNumberOfClusters;

			diskSpaceOut = new DiskSpace ();
			bResult = ApiNativeMethods.GetDiskFreeSpace(rootPathName, 
								out SectorsPerCluster, out BytesPerSector,
								out NumberOfFreeClusters, out TotalNumberOfClusters);

			diskSpaceOut.SectorsPerCluster		= SectorsPerCluster;
			diskSpaceOut.BytesPerSector			= BytesPerSector;
			diskSpaceOut.NumberOfFreeClusters	= NumberOfFreeClusters;
			diskSpaceOut.TotalNumberOfClusters	= TotalNumberOfClusters;
			diskSpaceOut.FreeBytes				= (long)(NumberOfFreeClusters)  * (long)(SectorsPerCluster) * (long)(BytesPerSector);
			diskSpaceOut.TotalBytes				= (long)(TotalNumberOfClusters) * (long)(SectorsPerCluster) * (long)(BytesPerSector);
			return bResult;
		}