473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting Only Non-Hidded and Non-System Directories

I am getting the list of subdirectories from a specified directory using
System.IO.Directory.GetDirectories(), 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.Directory.GetDirectories(). 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********@hotmail.com
http://www.nathansokalski.com/
Oct 16 '07 #1
3 4287
On Oct 15, 5:53 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I am getting the list of subdirectories from a specified directory using
System.IO.Directory.GetDirectories(), 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.Directory.GetDirectories(). 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...@hotmail.comhttp://www.nathansokalski.com/
You can use System.IO.DirectoryInfo.GetDirectories 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*********@comcast.netwrote in message
news:11**********************@y27g2000pre.googlegr oups.com...
On Oct 15, 5:53 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I am getting the list of subdirectories from a specified directory using
System.IO.Directory.GetDirectories(), 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.Directory.GetDirectories(). 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...@hotmail.comhttp://www.nathansokalski.com/

You can use System.IO.DirectoryInfo.GetDirectories 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...@hotmail.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...@comcast.netwrote in message

news:11**********************@y27g2000pre.googlegr oups.com...
On Oct 15, 5:53 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I am getting the list of subdirectories from a specified directory using
System.IO.Directory.GetDirectories(), 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.Directory.GetDirectories(). 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...@hotmail.comhttp://www.nathansokalski.com/
You can use System.IO.DirectoryInfo.GetDirectories 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.GetDirectories()

If (d.Attributes And FileAttributes.System) <>
FileAttributes.System Then
Console.WriteLine(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
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...
5
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...
8
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...
0
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...
3
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...
32
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...
2
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...
0
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:...
4
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...
3
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...

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.