I'm using an excellent example here to get my list of drives. It seems to be working but I'm pretty sure I have a logic error as it only lists my last "Local" and my last "Network" drives. If anyone can offer a suggestion, that'd be great.
Here's my code:
protected void Page_Load(object sender, EventArgs e)
{
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
bool isLocal = IsLocalDrive(drive.Name);
if (isLocal)
{
loc = drive.Name;
}
else
{
net = drive.Name;
}
}
local = loc + " ~ ";
network = net + " ~ ";
}
and
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Local drives: " + local;
Label2.Text = "Network drives: " + network;
}
this produces only:
Local drives: D:\ ~
Network drives: Z:\ ~
Whereas I had expected:
Local drives: A:\ ~ C:\ ~ D:\ ~
Network drives: H:\ ~ I:\ ~ J:\ ~ P:\ ~ U:\ ~ V:\ ~ W:\ ~ X:\ ~ Z:\ ~