How to determine Available memory

  • Thread starter Thread starter Ole
  • Start date Start date
O

Ole

How do I determine the available amount of memory in a Pocket PC (code
example)? I need to check if there is space enough for saving data before
doing it.

Thanks
Ole
 
So, you don't want to know the amount of available memory, but the amount of
available disk space? I'm not sure that you will ever be able to reliably
predict ahead of time whether X is enough memory to save a file of size Y or
not. You have to deal with cluster sizes, just like you do on the desktop
when saving to disk. You can take a look at GetDiskFreeSpaceEx() in the C
SDK. You should be able to P/Invoke to that. Probably the 'right' way is
to just try to save and, if you get a disk-full exception, report that to
the user or take suitable automatic action as a result. I don't see
DriveInfo in .NET Compact Framework, so I think that P/Invoking is probably
going to be necessary.

Paul T.
 
Back
Top