473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

retreive space on network drives

sam
What is the quickest way to retreive total space and free
space for the network drivers.

Sam
Nov 15 '05 #1
2 3022
Sam,

The easiest way would be to call the GetDiskFreeSpaceEx API function
through the P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sam" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
What is the quickest way to retreive total space and free
space for the network drivers.

Sam

Nov 15 '05 #2
Here is how to get the free space of a networked drive using
System.Management and WMI.
It's important to note that the free space could be incorrect when
user-quotas are applied.

using System;
using System.Management;
class Tester {
public static void Main() {
GetFreeSpace(@"\\\\scenic\\kdrive");
}
public static void GetFreeSpace(string ProviderName )
{
// Needs XP or higher
String strSQL = "SELECT FreeSpace, QuotasDisabled ,VolumeName FROM
Win32_LogicalDisk WHERE providername='" + ProviderName + "'" ;
SelectQuery query = new SelectQuery(strSQL);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject mo in searcher.Get()) {
// If both properties are null I suppose there's no CD
if(mo["QuotasDisabled"].ToString() != "true")
Console.WriteLine("{0} - Free bytes: {1} ",mo["VolumeName"],
mo["Freespace"]);
else
Console.WriteLine("{0} - Free bytes: {1} per-user quota's
applied!!",mo["VolumeName"], mo["Freespace"]);

}
}
}

Willy.

"sam" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
What is the quickest way to retreive total space and free
space for the network drivers.

Sam

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BuddyWork | last post by:
Hello, I need to know how I can check if the drives on my machine are network drives and local drives via the .Net framework. For example my PC has the following drives C: Local D: Local N:...
4
by: andrewcw | last post by:
If I have a drive letter I can get the the drive info from WMI like this string ltrDr=theSharePath.Substring(0,2); // must be in form of "E: string wackyQuery...
6
by: Default User | last post by:
Hi How can i look for network share folders and copy a text file to it? I've been looking into how i can do this in the documention but with no luck. I found a little on of the web but i dont...
2
by: Pradeep Sundaram(MSFT) | last post by:
Hello, I want to enumerate all the Drives on the web server using ASP.NET (C#) Writing code like this works when i use local host but when i try to access it from another machine it does not show...
11
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read...
1
by: Dennis | last post by:
I use the below code to get the Network Places items. However, this requires "Late Binding". I read that you can avoid late binding by adding a reference to the Com Types in your application. ...
0
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with...
2
by: =?Utf-8?B?ZGdjb29wZXI=?= | last post by:
When I get a list of drives using the Directory.GetLogicalDrives(), it gives me all drives including disconnected network drives. When I attempt to use Directory.GetDirectories() on a disconnected...
2
by: Lidia | last post by:
Input: A computer name on the internal network Out: Disk space total and remaining on all drives.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.