By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

Find drives in the PC

P: n/a
I have a program in the network location, which when running, it needs
to find out what are all the drives available in the PC. I have the
following code in my program

using (ManagementClass netwConn = new
ManagementClass("Win32_NetworkConnection"))
{
ManagementObjectCollection shares =
netwConn.GetInstances();
foreach (ManagementObject share in shares)
{
Console.WriteLine("{0} - {1}", share["LocalName"],
share["RemotePath"]);
if (path.Equals(share["RemotePath"].ToString()))
return share["LocalName"].ToString();
}
return "";
}
I realised that since the application is invoked from the server, it
might be trying to find the drives in the server insteaded of my PC.
Is this a correct if so, how can I identify all the drives available
in the PC itself instead of Server?

Oct 16 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"DBC User" <db*****@gmail.comwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...
>I have a program in the network location, which when running, it needs
to find out what are all the drives available in the PC. I have the
following code in my program

using (ManagementClass netwConn = new
ManagementClass("Win32_NetworkConnection"))
{
ManagementObjectCollection shares =
netwConn.GetInstances();
foreach (ManagementObject share in shares)
{
Console.WriteLine("{0} - {1}", share["LocalName"],
share["RemotePath"]);
if (path.Equals(share["RemotePath"].ToString()))
return share["LocalName"].ToString();
}
return "";
}
I realised that since the application is invoked from the server, it
might be trying to find the drives in the server insteaded of my PC.
Is this a correct if so, how can I identify all the drives available
in the PC itself instead of Server?

You can use System;IO.GetDrives to retrieve the *local* disk drives actually
connected to your system.

Willy.
Oct 16 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.