473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting list of folders in location

I need to find all the folders at a certain location, and then once I
have this list of folders I need to add some of them to a collection and
then show the names of those folders on screen (there are certain
folders that I do not want show on screen so I need to be able to have a
foreach loop once I have all the folder names where I can check for
folder names I don't want).

Does anybody know how to do this?
*** Sent via Developersdex http://www.developersdex.com ***
Oct 9 '08 #1
2 2142

"Mike P" wrote:
I need to find all the folders at a certain location, and then once I
have this list of folders I need to add some of them to a collection and
then show the names of those folders on screen (there are certain
folders that I do not want show on screen so I need to be able to have a
foreach loop once I have all the folder names where I can check for
folder names I don't want).

Does anybody know how to do this?
Hi Mike,

The Directory class have methods for retrieving a list of files and folders.
Using an overloaded GetDirectories method you can also specify a filter and
thereby possibly preventing the need for looping through the result.

If you get stuck tell us where and we will help you further.

--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 9 '08 #2
Hi Morten,

I have got to the point where I can return all the folders, but now I
need to remove from that collection the folders that I don't want.
Basically if the folder is called 'additional' or 'notes' then I want to
ignore it. Here is my code so far :

string strPath = Server.MapPath(@"Files\" + FolderName);
DirectoryInfo objCurrentDirectory = new
DirectoryInfo(strPath);
DirectoryInfo[] aryDirectories =
objCurrentDirectory.GetDirectories();

Could I use GetDirectories to screen out these 2 folders if they exist?


*** Sent via Developersdex http://www.developersdex.com ***
Oct 9 '08 #3

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

Similar topics

5
by: Konrad L. M. Rudolph | last post by:
I hope this is the right NG, please notify me if not. I have got a problem with the "recent files" list of the start page in VS.NET: yesterday I created a new projekt which has the same name as...
5
by: Krustov | last post by:
<?php $dirname = "."; $dh = opendir($dirname); while ($file = readdir($dh)) { if (is_dir ("$dirname/$file")) { print ""; } print "$file<br>";
6
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been...
0
by: Jurjen de Groot | last post by:
I have build an ASP.NET application and would like to protect various folders containing aspnet pages for various usertypes. /Admin /Manager /User I've created a login on the default.aspx in...
1
by: Locke Nash Cole | last post by:
I'm making a utility similar to MSConfig, I've found it easy enough to obtain the startup items from the registry for the current user and local machine... but what about the Startup folder on the...
2
by: Cesar Ronchese | last post by:
Hello, I'm experiencing a very weird problem. I have a ASP.Net 2005 application (VB.Net) that creates some folders to store temporary files. example: Session_Start(...)...
3
by: sva | last post by:
Using C# for an application in which I am working on, I need to display the available shared folders on the computer that's running the application. The shared folder paths need to be in UNC format...
1
by: lecnac | last post by:
Sorry for the repost. I must have done something wrong when I tried to post my reply (I can't seem to find it). Anyway, I'd really appreciate any help that anyone could provide. My issue is...
2
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 with Apache 2 on Fedora Core 6 Linux. Given a directory, how would I get all sub-directories? I found "scandir" but that only applies for PHP 5 and I think it returns...
0
marktang
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
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...
0
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...
0
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 ...
0
muto222
php
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.