check disk space of a network drive

A

adiel_g

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
 
M

Matt Lacey

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();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top