nag
nag

Reputation: 930

In asp.net how to get drives collections from computer to my DropDownList?

I've a DropDownList and i need to fill it with number of drives available in my computer like C:\, D:\ etc... so how can i do this one? help me.

Thanks, @nagaraju.

Upvotes: 0

Views: 223

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94643

Use System.IO.DriveInfo class.

System.IO.DriveInfo []drives = System.IO.DriveInfo.GetDrives();
foreach(var drive in drives)
  {
    DropDownList1.Items.Add(drive.Name);
  }

Upvotes: 1

Related Questions