friendsterTalk - Friendster Forum

friendsterTalk - Friendster Forum

Welcome guest! Please Login or Register.

#1  2008-11-11 17:34:14

creamownedz
 active server protocol
creamownedz's display avatar
» FriendsterTalker
PsychoCoder
Class-S
Location: Ftalk & MCTF
Registered: 2008-03-22
Posts: 115
Last visit: Yesterday
Reputation: 7

Populate a TreeView with all drives in system [C#]

This is a small snippet that will load all the drive types into a TreeView



Instructions: treeDrives is the name of the TreeView I used, you may need to change it to match your name



Code:

private void LoadDriveTypes()
          {
               DriveInfo[] driveList = DriveInfo.GetDrives();
               // Loop through the list of drives
               foreach (DriveInfo drive in driveList)
               {
                // Determine what kind of drive it is
                switch (drive.DriveType)
                {
                    // It's a HDD
                    case DriveType.Fixed:
                        treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 3);
                        break;
                    //// It's a CD-ROM, DVD-ROM, CD-RW, DVD+-RW or any other similar drive
                    case DriveType.CDRom:
                        treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 0);
                        break;
                    //// It's a floppy drive (or other removable drive, i.e; USB Flash Drive)
                    case DriveType.Removable:
                        treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 2);
                        break;
                    //// It's a network drive
                    case DriveType.Network:
                        treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 4);
                        break;
                    //// It's a RAM drive
                    case DriveType.Ram:
                        treeDrives.Nodes.Add(drive.ToString(), drive.ToString(), 6);
                        break;
                }
               }
          }

...Giving of reputation are highly appreciating for me...
Computers don't make errors what they do they do on purpose
...computer is my expertise...
....an addicted coder....
....don't ripp all my tutorials....

Search Friendstertalk

Board footer

FriendsterTalk is not affiliated with Friendster.com
Copyright © 2002–2009 PunBB

[ 8 queries - 0.027 second ]

Pay Per Click Ads by pay per click advertising by Kontera

FriendsterTalk.com x

Welcome to FriendsterTalk! You'll need to login in order to fully use all the features and view all the sections of this site.

Please register if you're not yet a member. =)