Matt
Thu Dec 13 06:29:51 PST 2007
On 12 Dec, 18:40, adie...@hotmail.com wrote:
> Does anyone know how to check diskspace of a network drive? The below
> code works only for local drives.
>
> The following returns an error "Object must be a root directory("C:\")
> or a drive letter ("C"):
>
> Dim di As System.IO.DriveInfo = New System.IO.DriveInfo("\\SERVER01\C
> $")
> Dim totalspace As Long = di.TotalSize
>
> Thanks Before Hand,
> Adiel
Map the drive to a letter and then do it. Something like:
(Using the tool from:
http://www.codeproject.com/KB/system/mapnetdrive.aspx)
NetworkDrive drive = new NetworkDrive();
drive.ShareName = @"\\SERVER01\C$";
drive.LocalDrive = "Z";
drive.Force = true;
drive.MapDrive(@"DOMAIN\USERNAME", "password");
System.IO.DriveInfo di = new System.IO.DriveInfo("z");
Console.WriteLine (di.AvailableFreeSpace);
drive.UnMapDrive();