How do I get the size (free, total) of any drive on a Windows Mobile phone using C#?
I need to do this with code running on the device (not on a connected PC).
Assuming the phone's drive is mounted as a regular volume in Windows (i.e., it has a drive letter in Windows Explorer), you can obtain this information using the System.IO.DriveInfo class.
Next problem, of course, would be to determine which drive letter to use, as that will be different on just about every PC the phone is plugged into.
A couple of options for that:
And in case you want to run your code directly on the phone, and not on the PC it's attached to (your question doesn't elaborate on that...), this StackOverflow question shows how to obtain free space information on the Compact Framework.
EDIT, in response to the elaboration that "when i use DriveInfo and give it the drive symbol it gives me the size of the local drive " My C: drive " not the C drive exists on the mobile": the C: drive of the phone will have a different drive letter (for example, F:) on the PC it's mounted on -- therefore the part of my answer that talks about finding the right drive letter. This does, of course, assume that your phone's drive is made available in its entirety on the host PC: depending on the phone model, this may or may not be the case. If not, running some code on your phone is the only viable solution for getting this information...