Smartphone 2003SE - Get Storage Card Diskspace

  • Thread starter Thread starter Guest
  • Start date Start date
juvi said:
Hi,

I want to get the totalBytes and the availBytes. My problem is now, that the
totalByte size equals the availByte size. What is wrong?
I use the public class MemStatus from
http://www.dotnetfordevices.com/snippets/8.html

thank you...juvi


Look at tese lines:

// ---------------------------------
public static bool GetStorageInfo (
string storagePath,
out ulong totalBytes,
out ulong availBytes)
{
ulong freeBytesAvail;
ulong totalBytesAvail;
ulong freeBytesTotal;
bool result = GetDiskFreeSpaceEx (storagePath,
out freeBytesAvail,
out totalBytesAvail,
out freeBytesTotal);

if (result == true)
{
totalBytes = ulong.totalBytesAvail;
availBytes = ulong.freeBytesAvail;
}
else
{
totalBytes = ulong.MaxValue;
availBytes = ulong.MaxValue;
}
<snap>
//----------------------------------

Are yuo sure GetDisSpaceEx returns true? Otherwize both values will be equal

Andrey
 
I use this class:

public class MemoryStatus
{
[DllImport("coredll.dll")]
public static extern bool GetDiskFreeSpaceEx (
string lpDirectoryName,
out ulong lpFreeBytesAvailableToCaller,
out ulong lpTotalNumberOfBytes,
out ulong lpTotalNumberOfFreeBytes
);

//public const string STORAGE_INTERNAL = "\\";
//public const string STORAGE_CARD = "\\storage card\\";

public MemoryStatus()
{
}

public static void GetStorageInfo (string storagePath, out int
totalBytes, out int availBytes)
{


ulong freeBytesAvail, totalBytesAvail, freeBytesTotal;
bool result = GetDiskFreeSpaceEx(storagePath, out freeBytesAvail, out
totalBytesAvail, out freeBytesTotal);

if (result == true)
{
totalBytes = Convert.ToInt32(totalBytesAvail);
availBytes = (int)freeBytesAvail;
}
else
{
totalBytes = -1;
availBytes = -1;
}
}
}

It returns true for me. but then I always get 120MB/120MB!? What do you
think?...juvi
 
Back
Top