|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Directory.Getfiles search patternIs there a way to limit the search pattern for Directory.Getfiles to
an exact number of characters. For example I want to see all the files fitting the pattern "*.abc" but excluding "*.abcd". The default behaviour seems to include .abcd when searching for just"*.abc", which I suppose is logical in one way, but not what I want. JGD Hello John,
> Is there a way to limit the search pattern for Directory.Getfiles to Have you tried """*.abc""" ? I've read in an article that on shell you> an exact number of characters. For example I want to see all the files > fitting the pattern "*.abc" but excluding "*.abcd". The default > behaviour seems to include .abcd when searching for just"*.abc", which > I suppose is logical in one way, but not what I want. can limit it to only the exact match if you place "" around. Regards Holger On Tue, 14 Nov 2006 16:53:20 +0100, "Holger Boskugel"
<news.p***@vbwebprofi.de> wrote: >Have you tried """*.abc""" ? I've read in an article that on shell you Thanks for the idea but 'Illegal characters in path' runtime error>can limit it to only the exact match if you place "" around. > with """*.abc""" (sic). ""*.abc"" gives a design time error. Looks like I might have to do "*.abc" and then weed out the unwanted file names but it's a pain and not totally trivial to code in my proc, which places the results of the Directory.Getfiles in a string array. The array is then used for other purposes. Nothing insuperable of course, just a little messy. Getting the desired result from "*.abc" would have made life significantly simpler. JGD > Looks like I might have to do "*.abc" and then weed out the unwanted It's quite trivial to weed out the unwanted items, try something like the > file names but it's a pain and not totally trivial to code in my proc. following: Dim theFiles() As String = Directory.GetFiles(thePath, thePattern) Dim theList As New List(Of String) For Each theFile As String In theFiles If <implement search pattern> (theFile) then theList.Add(theFile) End If Next theFiles = theList.ToArray() Hello John,
Show quoteHide quote > >Have you tried """*.abc""" ? I've read in an article that on shell you If this is not working, so you should use the solution Robinson> >can limit it to only the exact match if you place "" around. > > > > Thanks for the idea but 'Illegal characters in path' runtime error > with """*.abc""" (sic). > > ""*.abc"" gives a design time error. > > Looks like I might have to do "*.abc" and then weed out the unwanted > file names but it's a pain and not totally trivial to code in my proc, > which places the results of the Directory.Getfiles in a string array. > The array is then used for other purposes. Nothing insuperable of > course, just a little messy. Getting the desired result from "*.abc" > would have made life significantly simpler. mentioned. Regards Holger
Application performance decrease after deleting rows
Reading value of a bit? how to use variable to refer to a control? Check for Duplicate Appointment Times Hiding Default Constructor in VB Express 2005 (Public Not Creatable in VB6) Cannot open a database from a previous version of your application compare/check character against an array of chars - best practice? Help!! Dynamic Textbox, validation requiredFieldValidator testing if .NET Framework 2.0 is installed Database & Datagrid issues |
|||||||||||||||||||||||