471,599 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Getting Volume serial number and other information

Hi group
I'm trying to implement a console application which work just lie "Dir"
instruction in MS-Dos prompt window so I need to display Volume Serial Number
and also the free space, how can I get Volume Serial Number and other related
informations and is there any function in .Net which will return the
available free space in a specified drive?
Regards,
Nov 17 '05 #1
3 3907
All you need to do is use WMI

got to:
http://msdn.microsoft.com/library/de...asp?frame=true

Its easy

"Jefe" <Je**@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Hi group
I'm trying to implement a console application which work just lie "Dir"
instruction in MS-Dos prompt window so I need to display Volume Serial
Number
and also the free space, how can I get Volume Serial Number and other
related
informations and is there any function in .Net which will return the
available free space in a specified drive?
Regards,

Nov 17 '05 #2
Hi Ian
Thanx for your reply but could you please explain more or give an example in
C#

"Ian Frawley" wrote:
All you need to do is use WMI

got to:
http://msdn.microsoft.com/library/de...asp?frame=true

Its easy

"Jefe" <Je**@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Hi group
I'm trying to implement a console application which work just lie "Dir"
instruction in MS-Dos prompt window so I need to display Volume Serial
Number
and also the free space, how can I get Volume Serial Number and other
related
informations and is there any function in .Net which will return the
available free space in a specified drive?
Regards,


Nov 17 '05 #3
Taking no credit for this as I ripped it off: there are lots of examples on
the net

//Connection credentials to the remote computer - not needed if the logged
in account has access
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "JohnDoe";
oConn.Password = "JohnsPass";

System.Management.ManagementScope oMs = new
System.Management.ManagementScope("\\MachineX", oConn);

//get Fixed disk stats
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select FreeSpace,Size,Name from
Win32_LogicalDisk where DriveType=3");

//Execute the query
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);

//Get the results
ManagementObjectCollection oReturnCollection = oSearcher.Get();

//loop through found drives and write out info
foreach( ManagementObject oReturn in oReturnCollection )
{
// Disk name
Console.WriteLine("Name : " + oReturn["Name"].ToString());
// Free Space in bytes
Console.WriteLine("FreeSpace: " + oReturn["FreeSpace"].ToString());
// Size in bytes
Console.WriteLine("Size: " + oReturn["Size"].ToString());
}

"Jefe" <Je**@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
Hi Ian
Thanx for your reply but could you please explain more or give an example
in
C#

"Ian Frawley" wrote:
All you need to do is use WMI

got to:
http://msdn.microsoft.com/library/de...asp?frame=true

Its easy

"Jefe" <Je**@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
> Hi group
> I'm trying to implement a console application which work just lie "Dir"
> instruction in MS-Dos prompt window so I need to display Volume Serial
> Number
> and also the free space, how can I get Volume Serial Number and other
> related
> informations and is there any function in .Net which will return the
> available free space in a specified drive?
> Regards,


Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by misc | last post: by
3 posts views Thread by Jeff Gaines | last post: by
reply views Thread by Matthew Connor | last post: by
4 posts views Thread by Benjamins via AccessMonster.com | last post: by
reply views Thread by leo001 | last post: by

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.