How not to get hidden files :-)

  • Thread starter Thread starter Saranjit Singh
  • Start date Start date
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
 
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
 
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.
 
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 :-(
 
Back
Top