Name space:
using System.Runtime.InteropServices;
Code:
namespace _YournameNamespace
{
public class _YourClassName
{
/**Add this code after main class**/
[DllImport("kernel32")]
public static extern int GetDiskFreeSpace(string lpRootPathName,out int lpSectorsPerCluster,
out int lpBytesPerSector,out int lpNumberOfFreeClusters,out int lpTotalNumberOfClusters);
[DllImport("kernel32")]
public static extern int GetDiskFreeSpaceEx(string lpDirectoryName,ref double lpFreeBytesAvailable,ref double lpTotalNumberOfBytes,ref double lpTotalNumberOfFreeBytes
);
/**Add this code into your class or next to the above code**/
public static string OwnClass
{
int lpSectorsPerCluster;
int lpBytesPerSector;
int lpNumberOfFreeClusters;
int lpTotalNumberOfClusters;
double FreeBytesAvailable = 0;
double TotalNumberOfBytes = 0;
double TotalNumberOfFreeBytes = 0;
//Whatever shared directory path
DirectoryName = @\\ServerName\ShareName\;
int bRC = GetDiskFreeSpace(DirectoryName, out lpSectorsPerCluster, out lpBytesPerSector, out lpNumberOfFreeClusters, out lpTotalNumberOfClusters);
bRC = GetDiskFreeSpaceEx(DirectoryName, ref FreeBytesAvailable, ref TotalNumberOfBytes, ref TotalNumberOfFreeBytes);
}
}
//FreeBytesAvailable having disk avai space
//TotalNumberOfBytes totla space fo disk
24.6.08
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment