473,382 Members | 1,386 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,382 software developers and data experts.

How to get Drivelist including CD's & floopy drive info ..?

Hi all,
1. I want to list all the drives available in my system using C#..?
2. I want to check whether CD is inserted in CD-R or not.?

please suggest some resources for this..

Maheshkumar.R
http://spaces.msn.com/members/cyberiafreak


Nov 17 '05 #1
8 7514

You can do thiw with WMI (System.Management) if you want.
1. I want to list all the drives available in my system using C#..?
Enumerate Win32_LogicalDisk instances.

2. I want to check whether CD is inserted in CD-R or not.?


Enumerate Win32_CDROMDrive instances and check the MediaLoaded
property.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2

You can do thiw with WMI (System.Management) if you want.
1. I want to list all the drives available in my system using C#..?
Enumerate Win32_LogicalDisk instances.

2. I want to check whether CD is inserted in CD-R or not.?


Enumerate Win32_CDROMDrive instances and check the MediaLoaded
property.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #3
Hi Mattias Sjögren..., I solved very simply with the following code written
by me with the guidance of MSDN.

//////////////////////////////////////// code to list the logical drives in
C# ////////////////////////

string[] dList = Directory.GetLogicalDrives();

for (int z = 0; z < dList.Length; z++)

{

DriveInfo drv = new DriveInfo(dList[z]);

if (drv.DriveType.ToString() == "CDRom")

{

MessageBox.Show(" Yes i got the directory..!!");

DirectoryInfo dInfo = new DirectoryInfo(drv.Name);

if (!dInfo.Exists)

throw new DirectoryNotFoundException("Directory does not exist....." + drv);

foreach (DirectoryInfo di in dInfo.GetDirectories())

{

MessageBox.Show(di.ToString());

loadFolderfiles(di.Name);

}

}

////////////////////////////////////////////////////////////////////////////
//////////////////////////////

Maheshkumar.R

www.snipurl.com/guac


"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...

You can do thiw with WMI (System.Management) if you want.
1. I want to list all the drives available in my system using C#..?


Enumerate Win32_LogicalDisk instances.

2. I want to check whether CD is inserted in CD-R or not.?


Enumerate Win32_CDROMDrive instances and check the MediaLoaded
property.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #4
Hi Mattias Sjögren..., I solved very simply with the following code written
by me with the guidance of MSDN.

//////////////////////////////////////// code to list the logical drives in
C# ////////////////////////

string[] dList = Directory.GetLogicalDrives();

for (int z = 0; z < dList.Length; z++)

{

DriveInfo drv = new DriveInfo(dList[z]);

if (drv.DriveType.ToString() == "CDRom")

{

MessageBox.Show(" Yes i got the directory..!!");

DirectoryInfo dInfo = new DirectoryInfo(drv.Name);

if (!dInfo.Exists)

throw new DirectoryNotFoundException("Directory does not exist....." + drv);

foreach (DirectoryInfo di in dInfo.GetDirectories())

{

MessageBox.Show(di.ToString());

loadFolderfiles(di.Name);

}

}

////////////////////////////////////////////////////////////////////////////
//////////////////////////////

Maheshkumar.R

www.snipurl.com/guac


"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...

You can do thiw with WMI (System.Management) if you want.
1. I want to list all the drives available in my system using C#..?


Enumerate Win32_LogicalDisk instances.

2. I want to check whether CD is inserted in CD-R or not.?


Enumerate Win32_CDROMDrive instances and check the MediaLoaded
property.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #5
Wow....I want a floopy drive :^)
Nov 17 '05 #6
Wow....I want a floopy drive :^)
Nov 17 '05 #7
Hi Butler,

String[] dirs = Directory.GetLogicalDrives(); // this line will get u all
the drives in your computer. Just iterate thru one by by and catch the
floppy drive presence or not..

foreach (string dir in dirs)

{

// if (dir == @"C:\")

// MessageBox.Show("Selected");

}
Maheshkumar.R
http://spaces.msn.com/members/cyberiafreak
"Bill Butler" <qw****@asdf.com> wrote in message
news:vHROe.12539$3%1.12254@trndny08...
Wow....I want a floopy drive :^)

Nov 17 '05 #8
Hi Butler,

String[] dirs = Directory.GetLogicalDrives(); // this line will get u all
the drives in your computer. Just iterate thru one by by and catch the
floppy drive presence or not..

foreach (string dir in dirs)

{

// if (dir == @"C:\")

// MessageBox.Show("Selected");

}
Maheshkumar.R
http://spaces.msn.com/members/cyberiafreak
"Bill Butler" <qw****@asdf.com> wrote in message
news:vHROe.12539$3%1.12254@trndny08...
Wow....I want a floopy drive :^)

Nov 17 '05 #9

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

Similar topics

5
by: Jonathan | last post by:
I am creating a CD-ROM based website template. Things work fine under Windows but when I try to run the site under Linux the path is messed up. Therefore my JavaScript functions misinterpret the...
0
by: martin | last post by:
I want to read the additional data from audio cd's that is provided on subchannels or as CD-Text on the disc (like ISRC code, Artist name etc.). So far i could only find external .dll's or code...
7
by: GregT | last post by:
I program in C#. Is there a way to determine which of the local machine's logical drives are associated with CD drive(s)?
2
by: Alex Heiphetz | last post by:
Hi; I ran into a (of course :-) weird problem: have a simple MS-Access program that runs perfectly from hard drive, but when the program and corresponding database are copied onto CD, I get...
4
by: Jedi10180 | last post by:
I am trying to open a pdf file from a CD in my VB app. I'm using System.Diagnositcs.Process.Start to open the file, but I can't use d:\file.pdf because not all cd-rom drives are named d:\. How can...
3
by: Terry Olsen | last post by:
How can I find all CD/DVD drives on a system? And how can I tell if they are RW's? Thanks.
2
by: rodchar | last post by:
hey all, how do you programatically get the filenames of a disc in a CD R/RW Rom Drive? thanks, rodchar
2
by: KLynnM333 | last post by:
We have a Windows 2003 R2 SP2 webserver that is currently backed up using ntbackup (the Windows backup tool). Our backups are stored on a shared drive of our file/print server. The webserver...
1
by: samvb | last post by:
Hey, I have an old laptop that have no cd rom or floopy. I lost external flooppy actually. now, ntldr is missing and i wanna fix that using flash (i have done that before). But the laptop cant boot...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...

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.