code_junkie

Getting the size (free, total) of a Windows Mobile phone drive using C#

Nov 13th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public class MyClass
  2. {
  3. [DllImport("coredll.dll", SetLastError=true, CharSet=CharSet.Auto)]
  4. [return: MarshalAs(UnmanagedType.Bool)]
  5. internal static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
  6. out ulong lpFreeBytesAvailable,
  7. out ulong lpTotalNumberOfBytes,
  8. out ulong lpTotalNumberOfFreeBytes);
  9. }
  10.  
  11. ulong GetDiskSize(string volumeName)
  12. {
  13. ulong avail;
  14. ulong total;
  15. ulong totalfree;
  16.  
  17. MyClass.GetDiskFreeSpaceEx(volumeName, out avail, out total, out totalFree);
  18.  
  19. return total;
  20. // return others as desired
  21. }
  22.  
  23. ulong diskSize = GetDiskSize("\Storage Card");
Add Comment
Please, Sign In to add comment