Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Network drive size in C# (without "map drive")

Tags:

c#

I need to get the free space of a Network drive, without "map drive"

DriveInfo drvInfo = new DriveInfo("\\NetworkDrive");

I try to do this but it does not work.

like image 478
Hiyasat Avatar asked Jun 03 '10 12:06

Hiyasat


People also ask

How do I find out the size of my network drive?

How to check the available disk space / usage. In windows explorer, browse to the network share, then to the folder that you want to check the disk usage, right client on the folder and select properties. In the properties window, click on the "OES Info" tab, and check the "Space Available" field.

How do I check my C allocation space?

Go to File Explorer, and go to "This PC". Look for your default hard drive, which by default is (C:), and from there you can check your total space, and how much you have used.

How do I see disk size in CMD?

Search command prompt in Windows 10, and right-click on the result and choose Run as administrator. Step 2. Type wmic diskdrive get size and press Enter. Finally, the total size of hard disk space (in pure number) is displayed in the figure below.


1 Answers

I believe you will need to call GetDiskFreeSpace (Win32 API) via P/Invoke to get the disk free space of a UNC network drive.

e.g.

C# GetDiskFreeSpace UNC

like image 138
Mitch Wheat Avatar answered Oct 16 '22 05:10

Mitch Wheat