473,790 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find drives in the PC

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 (ManagementClas s netwConn = new
ManagementClass ("Win32_Network Connection"))
{
ManagementObjec tCollection shares =
netwConn.GetIns tances();
foreach (ManagementObje ct share in shares)
{
Console.WriteLi ne("{0} - {1}", share["LocalName"],
share["RemotePath "]);
if (path.Equals(sh are["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
1 1519
"DBC User" <db*****@gmail. comwrote in message
news:11******** **************@ y27g2000pre.goo glegroups.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 (ManagementClas s netwConn = new
ManagementClass ("Win32_Network Connection"))
{
ManagementObjec tCollection shares =
netwConn.GetIns tances();
foreach (ManagementObje ct share in shares)
{
Console.WriteLi ne("{0} - {1}", share["LocalName"],
share["RemotePath "]);
if (path.Equals(sh are["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.GetDr ives to retrieve the *local* disk drives actually
connected to your system.

Willy.
Oct 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3543
by: Mayer | last post by:
Hello: I'm running python under cygwin and need to find the drive letter. Cygwin has a way of calling my drives by a name relative to the Cygwin directory, so I get things like /home/user rather than /cygdrive/g/cygwin/home/usr, etc. How can I find the letter of the drive, or in the above example, the letter 'g'? My program needs to run on an external media that comes with Cygwin on it. I have no control over what drive is assigned to...
1
1607
by: Travis L. Alltop | last post by:
All, To make a long story short, we are swapping out the "knock-off" drives that the NA purchased on E-Bay in one of our production SQL Servers (SQL Server 2000 Enterprise) this weekend for brand new ones (Compaq 15K RPM 32GB drives). We are currently experiencing ASR almost on a daily basis and it is really causing a disription in service. SO, The Network Admin ahs made this decison to replace these drives in attempt to solve this....
36
4001
by: Ron Johnson | last post by:
http://hardware.devchannel.org/hardwarechannel/03/10/20/1953249.shtml?tid=20&tid=38&tid=49 -- ----------------------------------------------------------------- Ron Johnson, Jr. ron.l.johnson@cox.net Jefferson, LA USA I can't make you have an abortion, but you can *make* me pay child support for 18 years? However, if I want the child (and all the expenses that entails) for the *rest*of*my*life*, and you
4
14494
by: Jimi | last post by:
Given a C# project file path, can I use reflection to get all the assemblies referenced by the project? e.g., I know the path of a C# project, say, "c:\SomeProject.csproj", and I want to load its referenced assemblies to construct a list of their members for display. Note that "c:\SomeProject.csproj" is not the current project, it's just a project we're displaying information about in the utility I'm trying to construct.
0
2356
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with limited Success because there is a bug apparently in using IWshRuntimeLibrary. There must be some API calls to get this information since Windows Explorer seems to be able to get. Can anyone tell me what API's are used. I know GetLogicalDrivesA...
4
1679
by: Pieter | last post by:
Hi, I'm trying to get the whole UNC path of a file, and I would prefer to have it via a .NET-way (I'm using VB.NET 2005). So what I am basicly looking for is: X:\MyDirectory\MyFile.doc -> \\MyServer\MyShare\MyDirectory\MyFile.doc C:\MyDoc.doc -> \\MyComputer\C$\MyDoc.doc I found a way to have it for a mapped drive via WNetGetUniversalName, and normally I should be able to find it for a local harddisk via NetShareEnum,
2
1937
by: ImOk | last post by:
WHen I run this under Windows I get the Count of drives but then I get an error message on the Reset() when I try to enumerate. Does this work for anyone? $fs = new COM("Scripting.FileSystemObject"); $drives = $fs->Drives; echo $drives->Count; $drives->Reset(); while($drive = $drives->Next()) { echo $drive->VolumeName;
13
28395
usafshah
by: usafshah | last post by:
hi all i'm installing windows xp on Maxtor SATA 300 GB but setup prompts with the error of: setup did not find any hard disk drives.... its showing in bios I tried to download drivers for this but i didn't find on internet even on maxtor.com the problem is my hdd model is 6V300F0 which isn't listed in maxtor's HDD lists. :(
8
2438
by: Salad | last post by:
I was asked to get my daughter a flash drive. She needs to use it to copy files to it so she can transfer the files at school to her desktop at home. I've never used one but I figure some of you have. I see flash drives from on the net from 128 meg up to 16 gig. Prices range from $20 to $600. I see a lot of those ads referring to cameras. Are there USB flash drives specific for cameras and others for computers? Or do they all work...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.