|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dir(strPath, +R +A +S +H) keeps returning hidden foldersAll I want is to be able to search a file for files matching a certain criteria. However, VB seems heart set on returning hidden folders along with my list of files. I've tried the following: strFile = Dir(strPath, FileAttribute.Archive Or FileAttribute.Hidden Or FileAttribute.ReadOnly Or FileAttribute.System) and this which shouldn't be necessary strFile = Dir(strPath, FileAttribute.Archive Or FileAttribute.Hidden Or FileAttribute.ReadOnly Or FileAttribute.System AND FileAttribute.Directory) Either way I still turn up my hidden ".svn" subfolder. (The folder is hidden only, that is it's the only attribute, it's not system or anything else). I realize I could then do System.IO.File.Exists(strPath) to make sure it's actually a file, but that would double the disk access. Pretty lame if you ask me :). Thanks for any and all help regarding this matter, Christian Blackburn Hi,
Why not use the system.io.directoryinfo class to get the files. You can specify a search pattern for the files. Dim fi As System.IO.FileInfo Dim di As New System.IO.DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)) For Each fi In di.GetFiles("*.ppt") Trace.WriteLine(fi.Name) Next Ken ------------------- Show quoteHide quote "Christian Blackburn" <mypurcha***@Yahoo.com> wrote in message news:1136467257.383464.250390@g14g2000cwa.googlegroups.com... > Hi Gang, > All I want is to be able to search a file for files matching a certain > criteria. However, VB seems heart set on returning hidden folders > along with my list of files. I've tried the following: > strFile = Dir(strPath, FileAttribute.Archive Or FileAttribute.Hidden Or > FileAttribute.ReadOnly Or FileAttribute.System) > > and this which shouldn't be necessary > > strFile = Dir(strPath, FileAttribute.Archive Or FileAttribute.Hidden Or > FileAttribute.ReadOnly Or FileAttribute.System AND > FileAttribute.Directory) > > Either way I still turn up my hidden ".svn" subfolder. (The folder is > hidden only, that is it's the only attribute, it's not system or > anything else). > > I realize I could then do System.IO.File.Exists(strPath) to make sure > it's actually a file, but that would double the disk access. Pretty > lame if you ask me :). > > Thanks for any and all help regarding this matter, > Christian Blackburn > Hi Ken,
That's just too easy, you make me sick :). No just kidding that's great. I was trying for good performance though. However, I like the code and think I will use it in my search application, since in that I would be interested in all those file properties. Oh and I can also use it in my indexing page http://www.christianblackburn.com/misc/default.asp (obviously, I still need to convert this to ASP 2.0). Thanks for your help, you probably don't remember me, but I know you've helped me on a number of occasions. Possibly even in the VB6 group :). Cheers, Christian Blackburn Hi Ken,
That's just too easy, you make me sick :). No just kidding that's great. I was trying for good performance though. However, I like the code and think I will use it in my search application, since in that I would be interested in all those file properties. Oh and I can also use it in my indexing page http://www.christianblackburn.com/misc/default.asp (obviously, I still need to convert this to ASP 2.0). Thanks for your help, you probably don't remember me, but I know you've helped me on a number of occasions. Possibly even in the VB6 group :). That's doen't look recursive though, which is fine I can do recursion. Cheers, Christian Blackburn
Debugging in VS2005 - why is some code shaded grey?
alter built-in ContextMenu Microsoft doesn't want you to use VB .Net SqlConnection component in VB.2005 For each ..... next Question Setup and Deployment and Microsoft Jet OLE DB Provider Tip of Day Sending Emails from Code Solution rebuilding issues VS2005 Address Matching System |
|||||||||||||||||||||||