How not to get hidden files :-)

S

Saranjit Singh

Hi,

I am trying to get file listing that would ignore hidden files and folders.
But using the Directory.GetFiles method seems to get all files and folders
in the specified path irrespective of their hidden status. Any ideas or help
would be appreciated.

Thanks,
Saranjit
 
J

Jeremy Cowles

Saranjit Singh said:
Hi,

I am trying to get file listing that would ignore hidden files and folders.
But using the Directory.GetFiles method seems to get all files and folders
in the specified path irrespective of their hidden status. Any ideas or help
would be appreciated.

Thanks,
Saranjit

There *may* be a way to automate it, but you could definitly look at the
attributes of each file and preform a manual filter.

HTH,
Jeremy
 
A

Armin Zingler

Saranjit Singh said:
I am trying to get file listing that would ignore hidden files and
folders. But using the Directory.GetFiles method seems to get all
files and folders in the specified path irrespective of their hidden
status. Any ideas or help would be appreciated.


I don't think there is a built-in filter. If you'd use
System.IO.DirectoryInfo.GetFiles, you'd get FileInfo objects and could check
their attributes property without calling System.IO.File.GetAttributes on
each file.
 
S

Saranjit Singh

I could and I did try it out. The only problem is that the directory I am
searching has some 100,000 files or so. Getting the directory listing itself
takes quite a bit of time (especially so since it's not on the local
machine), so maybe if there's a way to filter the listing in the call to
some .NET Framework function ... looping and checking the attributes would
be too much in this case I guess.

And I would have to make quite a bit of changes to the application if
whatever method is suggested does not return the filenames as a string array
as the Directory.GetFiles method :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top