473,385 Members | 1,772 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,385 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 4144
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: misc | last post by:
Does anyone know how to access the Volume Serial Number of a drive using .NET? It is easily done in VB6 using the FilingSystemObject. I appreciate any insight into the matter.
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
3
by: Jeff Gaines | last post by:
I am using the 'ManagementObject' to get the volume name of each drive on my PC. It works but it is a bottleneck. Is there an quicker way to get this information? I am using C# but am happy yo...
3
by: Mark Harris | last post by:
I have an installer which uses a Customer Information page in it, is there an easy way to pass the serial number entered to a custom action? If not, where would i find the serial number in the...
7
by: ML | last post by:
What is the best/easiest means to return the serial/volume number of the drive containing the OS using VB.NET? I'm looking to get this information as a unique ID for activation/registration of a...
4
by: Frank | last post by:
Hello, how to get information about all serial ports in the PC? I use the following code, but i got only the data of the FIRST serial port. All other serial port information are not available...
6
by: Matthew Connor | last post by:
Hi all! I'm sure many of you rolled your eyes at the subject trying to recall how many times youv'e heard this question. :) But bear with because I THINK my question is at least slightly different...
0
by: Matthew Connor | last post by:
Hi all! I've posted a couple of times already today. Please forgive me but you all have been so helpful and I'd like to lean on your intelligence once again. I would like to change the volume...
4
by: Benjamins via AccessMonster.com | last post by:
Hi, I have used CreateObject("Scripting.FileSystemObject") to get the disk volume. Is there any other way of get the disk volume other than using the FSO. Thanks -- Message posted via...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.