Solved

DriveInfo and DriveType question

Posted on 2014-01-05
2
323 Views
Last Modified: 2014-01-05
DriveInfo info = new DriveInfo(drive);
        switch (info.DriveType)
        {
          case DriveType.CDRom:
            Console.WriteLine("CDROM drive");
            break;

Why does this code from a tutorial have "case DriveType.CdRom" instead of just "case CDRom"?

I thought that if info.DriveType is a property that returns a string, than it would return "CDRom". So why the leading DriveType in DriveType.CDRom?
0
Comment
Question by:BobHavertyComh
2 Comments
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 300 total points
ID: 39757742
>>I thought that if info.DriveType is a property that returns a string

Wrong.
http://msdn.microsoft.com/en-us/library/system.io.driveinfo.drivetype%28v=vs.110%29.aspx
info.DriveType returns a DriveType not a string, see:
http://msdn.microsoft.com/en-us/library/system.io.drivetype%28v=vs.110%29.aspx
0
 
LVL 10

Accepted Solution

by:
Korbus earned 200 total points
ID: 39757770
Anby is correct.  The value DriveType.CDROM, is technically called an ENUMERATION, (which usually equates to a particular number, behind the scenes), rather than a STRING.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question