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

How to get the size (free, shared) of any drive on a Windows Mobile phone using C #?

I need to do this using code running on a device (not on a connected PC).

0
source share
2 answers

I rewrote the answer based on a better understanding of the question, but without losing my original answer for those who find this question.

Getting size from code running on device

: P/Invoke GetDiskFreeSpaceEx ( ) , .

, , - , , .

P/Invoke. . . - :

public class MyClass
{
  [DllImport("coredll.dll", SetLastError=true, CharSet=CharSet.Auto)]
  [return: MarshalAs(UnmanagedType.Bool)]
  internal static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
    out ulong lpFreeBytesAvailable,
    out ulong lpTotalNumberOfBytes,
    out ulong lpTotalNumberOfFreeBytes);
}

( , ):

ulong GetDiskSize(string volumeName)
{
  ulong avail;
  ulong total;
  ulong totalfree;

  MyClass.GetDiskFreeSpaceEx(volumeName, out avail, out total, out totalFree);

  return total;
  // return others as desired
}

:

ulong diskSize = GetDiskSize("\\Storage Card");

,

"", . , . API- , P/Invoke, .

, ActiveSync (XP ) WMDC (Vista), Remote API RAPI. API CeGetStoreInformation, , .

RAPI , , , ( ) . , , RAPI.GetDeviceStoreInformation.

+5

, Windows (.. Windows), , System.IO.DriveInfo.

, , , , , , .

:

, , ( ...), fooobar.com/questions/1701271/... , Compact Framework.

EDIT, , " DriveInfo , " C: ", C ": C: (, F:) , , - . , , - : . , ...

+1

All Articles