O
Ofer B.
Is it possible to know the sd card memoty status with c#?
And of course, how?
Ofer
And of course, how?
Ofer
MemoryStatus.cs ----------------------Maarten Struys said:Here is a little sample, P/Invoking GetDiskFreeSpaceEx
--------------------------- file MemoryStatus.cs ----------------------
using System;
using System.Runtime.InteropServices;
namespace SmartDeviceApplication2
{
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;
}
}
}
}
--------------------------- end file