Exact Duplicate of: Getting the size (free,total) of a Windows Mobile phone drive using c#
dear all;
i know my problem took alot of time and many of u helped me but i'm new in C# and this is my first application..
now i read an article:
C# Signature:
[DllImport("coredll.dll", SetLastError=true, CharSet=CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
out ulong lpFreeBytesAvailable,
out ulong lpTotalNumberOfBytes,
out ulong lpTotalNumberOfFreeBytes);
Sample Code:
ulong FreeBytesAvailable;
ulong TotalNumberOfBytes;
ulong TotalNumberOfFreeBytes;
bool success = GetDiskFreeSpaceEx("C:\\", out FreeBytesAvailable, out
TotalNumberOfBytes,out TotalNumberOfFreeBytes);
if (!success)
throw new System.ComponentModel.Win32Exception();
Console.WriteLine("Free Bytes Available: {0,15:D}", FreeBytesAvailable);
Console.WriteLine("Total Number Of Bytes: {0,15:D}", TotalNumberOfBytes);
Console.WriteLine("Total Number Of FreeBytes: {0,15:D}", TotalNumberOfFreeBytes);
now how to use this function GetDiskFreeSpaceEx , and should i add C# signature to somewhere ?!? and what about the coredll.dll ?!?
my code is like that :
FolderInfo = (CONADefinitions.CONAPI_FOLDER_INFO)Marshal.PtrToStructure(Buffer,
typeof(CONADefinitions.CONAPI_FOLDER_INFO));
if (FolderInfo.pstrName[0].ToString() != "C" && level == 0)
{
// here i want to get the Total Size of the currentDirectory and freeSize
// i want them in Bytes
}
i searched on google but i dont have enough exprience to know the right tag
thnx