I need to eumerate all available drives in a C# Windows Form application (
and then of course the directory tree, but that's not the problem)
My question is, how to I enumerate all the available drives?
My initial thought was along the lines of
DirectoryInfo di = new DirectoryInfo( "c:\\");
DirectoryInfo Root = new DirectoryInfo( di.Parent.Name. ToString() );
DirectoryInfo[] RootDrives = Root.GetDirecto ries();
This, of course, doesn't work as the parent of c:\ is null.
For my immediate needs, I could simply loop through a:\, b:\, c:\... z:\,
test to see if the new DirectoryInfo(" x:\\") threw an error, and be
satisfied with that.
This seems, at least, to be crude. I also would like the ability to get UNC
shares.
Anyone have a solution?
Thanks
Phil 4 1341
"Phillip N Rounds" wrote: I need to eumerate all available drives in a C# Windows Form application ( and then of course the directory tree, but that's not the problem)
My question is, how to I enumerate all the available drives? My initial thought was along the lines of
DirectoryInfo di = new DirectoryInfo( "c:\\"); DirectoryInfo Root = new DirectoryInfo( di.Parent.Name. ToString() ); DirectoryInfo[] RootDrives = Root.GetDirecto ries();
This, of course, doesn't work as the parent of c:\ is null.
For my immediate needs, I could simply loop through a:\, b:\, c:\... z:\, test to see if the new DirectoryInfo(" x:\\") threw an error, and be satisfied with that. This seems, at least, to be crude. I also would like the ability to get UNC shares.
Anyone have a solution?
Thanks Phil
Hi Phillip,
To enumerate the drives you can use...
System.IO.Direc tory.GetLogical Drives();
John
"Phillip N Rounds" wrote: I need to eumerate all available drives in a C# Windows Form application ( and then of course the directory tree, but that's not the problem)
My question is, how to I enumerate all the available drives? My initial thought was along the lines of
DirectoryInfo di = new DirectoryInfo( "c:\\"); DirectoryInfo Root = new DirectoryInfo( di.Parent.Name. ToString() ); DirectoryInfo[] RootDrives = Root.GetDirecto ries();
This, of course, doesn't work as the parent of c:\ is null.
For my immediate needs, I could simply loop through a:\, b:\, c:\... z:\, test to see if the new DirectoryInfo(" x:\\") threw an error, and be satisfied with that. This seems, at least, to be crude. I also would like the ability to get UNC shares.
Anyone have a solution?
Thanks Phil
"Phillip N Rounds" <pr*****@cassan dragroup.com> schrieb: My question is, how to I enumerate all the available drives?
\\\
string[] drives = Environment.Get LogicalDrives() ;
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thanks
"Ssmoimo" <Ss*****@discus sions.microsoft .com> wrote in message
news:0E******** *************** ***********@mic rosoft.com... Hi Phillip,
To enumerate the drives you can use...
System.IO.Direc tory.GetLogical Drives();
John
"Phillip N Rounds" wrote:
I need to eumerate all available drives in a C# Windows Form application ( and then of course the directory tree, but that's not the problem)
My question is, how to I enumerate all the available drives? My initial thought was along the lines of
DirectoryInfo di = new DirectoryInfo( "c:\\"); DirectoryInfo Root = new DirectoryInfo( di.Parent.Name. ToString() ); DirectoryInfo[] RootDrives = Root.GetDirecto ries();
This, of course, doesn't work as the parent of c:\ is null.
For my immediate needs, I could simply loop through a:\, b:\, c:\... z:\, test to see if the new DirectoryInfo(" x:\\") threw an error, and be satisfied with that. This seems, at least, to be crude. I also would like the ability to get UNC shares.
Anyone have a solution?
Thanks Phil This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Frank Bechmann |
last post by:
yes, that's the simple question:
is there some python standard or 'Python for Windows Extensions'
functionality to iterate or list-return the available drives ('A:',
'B:', 'C:', ...) on a machine running windows?
Thx in advance.
|
by: Frank Bechmann |
last post by:
yes, that's the simple question:
is there some python standard or 'Python for Windows Extensions'
functionality to iterate or list-return the available drives ('A:',
'B:', 'C:', ...) on a machine running windows?
Thx in advance.
|
by: Pradeep Sundaram(MSFT) |
last post by:
Hello,
I want to enumerate all the Drives on the web server using ASP.NET (C#)
Writing code like this works when i use local host but when i try to access
it from another machine it does not show the network drives.
Code:
foreach (string s in arr)
{
s2=s2+s;
}
|
by: Tales Normando |
last post by:
Hi,
Can .NET enumerate all available IP addresses on a local network
or do I have to resort to Windows API? How?
Tales Normando
|
by: Jon Slaughter |
last post by:
I'm trying to make a tree list of possible storage devices for a small app
but I have no idea how to get them. I want something very similar to windows
explorer's tree view. Do I have to manually work with each one(hard drives,
USB drives, networks, etc, special locations, etc..) or is there some way to
get all these possibilities enumerated for me?
Thanks,
Jon
| |
by: Danny Colligan |
last post by:
In the following code snippet, I attempt to assign 10 to every index in
the list a and fail because when I try to assign number to 10, number
is a deep copy of the ith index (is this statement correct?).
.... number = 10
....
So, I have to resort to using enumerate to assign to the list:
|
by: bcanter |
last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is created they can tell me who they want their account to be modeled after. The html app works great as a .hta file but when it is saved as a web page it won't list the members of any groups. I get an error on line 182: "ActiveX component can't create...
|
by: Angus |
last post by:
Hello
I have a web page which uses a js file on the server. I cannot see all the
javascript functions available to me in the html. I would like to have a
function which could print eg to a DIV section, all the available functions.
Just the function names is fine.
Is there any way to do this in javascript?
Angus
|
by: Bruce Cleaver |
last post by:
Hello,
I've been trying to find a way to enumerate all drives- logical and virtual starting at the desktop for an explorer clone. I know how to get the logical drives and icons, but have not found a way to get all the drives and folders.
I think IShellFolder with enumobjects is used but I can't find an example.
Thank you for your help.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |