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.