// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Runtime.InteropServices; namespace E { public class MainClass { [DllImport("kernel32.dll", SetLastError=true)] static extern int GetDiskFreeSpaceA ( string lpRootPathName, ref int lpSectorsPerCluster, ref int lpBytesPerSector, ref int lpNumberOfFreeClusters, ref int lpTtoalNumberOfClusters); public static void Main(string[] args) { int spc = 0, bps = 0, fre = 0, tot = 0; GetDiskFreeSpaceA("C:", ref spc, ref bps, ref fre, ref tot); Console.WriteLine(((long)fre * spc * bps) + " of " + ((long)tot * spc * bps) + " is free"); } } }