473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting Only Non-Hidded and Non-System Directories

I am getting the list of subdirectories from a specified directory using
System.IO.Direc tory.GetDirecto ries(), and would like to get only
subdirectories that are not hidden or system directories. I did not notice
any way to do this using System.IO.Direc tory.GetDirecto ries(). Is there some
other function that I can use, or is there some way to determine whether a
directory is hidden or system? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Oct 16 '07 #1
3 4301
On Oct 15, 5:53 pm, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
I am getting the list of subdirectories from a specified directory using
System.IO.Direc tory.GetDirecto ries(), and would like to get only
subdirectories that are not hidden or system directories. I did not notice
any way to do this using System.IO.Direc tory.GetDirecto ries(). Is there some
other function that I can use, or is there some way to determine whether a
directory is hidden or system? Thanks.
--
Nathan Sokalski
njsokal...@hotm ail.comhttp://www.nathansokal ski.com/
You can use System.IO.Direc toryInfo.GetDir ectories to return an array
of DirectoryInfo objects. This object has an Attributes property,
which you can check to see if the system or hidden attributes are
applied.

--
Tom Shelton

Oct 16 '07 #2
Could you show me an example of how I test for these attributes? It seems
like the Attributes property has an enumeration containing Hidden and
System, but I am having trouble testing whether they are true for the
current DirectoryInfo. Thanks.

"Tom Shelton" <to*********@co mcast.netwrote in message
news:11******** **************@ y27g2000pre.goo glegroups.com.. .
On Oct 15, 5:53 pm, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
>I am getting the list of subdirectories from a specified directory using
System.IO.Dire ctory.GetDirect ories(), and would like to get only
subdirectori es that are not hidden or system directories. I did not
notice
any way to do this using System.IO.Direc tory.GetDirecto ries(). Is there
some
other function that I can use, or is there some way to determine whether
a
directory is hidden or system? Thanks.
--
Nathan Sokalski
njsokal...@hot mail.comhttp://www.nathansokal ski.com/

You can use System.IO.Direc toryInfo.GetDir ectories to return an array
of DirectoryInfo objects. This object has an Attributes property,
which you can check to see if the system or hidden attributes are
applied.

--
Tom Shelton
Oct 16 '07 #3
On Oct 16, 5:47 am, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
Could you show me an example of how I test for these attributes? It seems
like the Attributes property has an enumeration containing Hidden and
System, but I am having trouble testing whether they are true for the
current DirectoryInfo. Thanks.

"Tom Shelton" <tom_shel...@co mcast.netwrote in message

news:11******** **************@ y27g2000pre.goo glegroups.com.. .
On Oct 15, 5:53 pm, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
I am getting the list of subdirectories from a specified directory using
System.IO.Direc tory.GetDirecto ries(), and would like to get only
subdirectories that are not hidden or system directories. I did not
notice
any way to do this using System.IO.Direc tory.GetDirecto ries(). Is there
some
other function that I can use, or is there some way to determine whether
a
directory is hidden or system? Thanks.
--
Nathan Sokalski
njsokal...@hotm ail.comhttp://www.nathansokal ski.com/
You can use System.IO.Direc toryInfo.GetDir ectories to return an array
of DirectoryInfo objects. This object has an Attributes property,
which you can check to see if the system or hidden attributes are
applied.
--
Tom Shelton- Hide quoted text -

- Show quoted text -
Nathan,

Those attributes are flag attributes - so a simple bitwise and will
tell you if they have the attribute:

Option Strict On
Option Explicit On

Imports System
Imports System.IO

Module Module1
Sub Main()
Dim rootInfo As DirectoryInfo = New DirectoryInfo(" c:\")
For Each d As DirectoryInfo In rootInfo.GetDir ectories()

If (d.Attributes And FileAttributes. System) <>
FileAttributes. System Then
Console.WriteLi ne(d.Name)
End If
Next
End Sub
End Module

HTH,

--
Tom Shelton

Oct 17 '07 #4

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

Similar topics

2
6904
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on a type mismatch. It is positively because of the boolean(java primitive)parameter. It goes fine if I change this parameter to int or String. This inteface has a lot more methods which works fine, it is just the
5
1888
by: Francis Bell | last post by:
I just found that my fin stream is not getting passed to my readInASpinnerbait function. Here's what I have: string readInFirstChars(ifstream &fin) { char first; string print; while (fin.good()) { fin.get(first, 4, '/');
8
9998
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
0
2220
by: Si | last post by:
I'm writing an HttpModule to intecept web method calls and retrieve custom authentication information from their SOAP headers. I have the httpModules tag in web.config and that appears to be getting parsed okay. If I mangle the type attribute or try to add the module twice I get configuration errors as expected. So I "assume" that the module is getting loaded. Init() is not getting called, though, when I make a call to a web method...
3
3682
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the first part) needs to get input from the user, and I want to do this with cin.getline also. The problem I am getting, is when I run the program, the text if read in from the file correctly, but it seems to just skip over the cin.getline when I want...
32
4990
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is not a function" ---------------------------------------------------- I have this in a .js file and in the head section.
2
4209
by: MSK | last post by:
Hi, Continued to my earlier post regaring "Breakpoints are not getting hit" , I have comeup with more input this time.. Kindly give me some idea. I am a newbie to .NET, recently I installed .NET. I could not debug using breakpoints, breakpoints are not getting hit, but the application is working fine with out any issue.
0
1388
by: MSK | last post by:
Dear all, Continued to my earlier mail regarding "Breaking points are not getting hit in ASP.NET " , I got some idea from net. Can anyone give me more idea on this? Just to remind the issue: 1. I got the following error while executing a newly created a web application (just sample app)
4
4488
by: R.Manikandan | last post by:
Hi In my code, one string variable is subjected to contain more amount of characters. If it cross certain limit, the string content in the varabile is automatically getting truncated and i am not getting the full data. Is there any max limit for an variable to store in javascript? Can anyone please help me to solve this prob?
3
2353
by: wolverine | last post by:
Hi, I am injecting a javascript code into html pages and attaching some dom events to some elements via attachEvent (IE only). I just want to know that is there any chance by which my event handler not getting executed ? ie, is there some means for the web developer to prevent any further handler getting executed for the same event on the same element ? To be more clear, assume the web developer has attached function "f1()" on onclick...
0
7886
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8272
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...
1
8035
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
8258
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6688
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
5847
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
5431
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();...
1
2404
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
0
1238
bsmnconsultancy
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...

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.