Home All Groups Group Topic Archive Search About

File operation with user-set wildcards

Author
24 Aug 2006 1:56 PM
kenny
I want to delete files but I also want to set the wildcards manually. Look at
this example:

        If TextBox1.Text = "" Then
        Else
            For Each foundFile As String In
My.Computer.FileSystem.GetFiles(curdir & "\_res_original", _
            FileIO.SearchOption.SearchAllSubDirectories, TextBox1.Text)
                My.Computer.FileSystem.DeleteFile(foundFile)
            Next
        End If

------------

TextBox1.Text should look like <"*.exe", "*.txt", "*.ini">
It works with one extension but if I specify many of them, vb gives an error
that there is an illegal character. I suppose it handles the commas not
correctly.

Thanks for any help

Author
24 Aug 2006 8:08 PM
gene kelley
On Thu, 24 Aug 2006 06:56:01 -0700, kenny <ke***@discussions.microsoft.com> wrote:

Show quoteHide quote
>I want to delete files but I also want to set the wildcards manually. Look at
>this example:
>
>        If TextBox1.Text = "" Then
>        Else
>            For Each foundFile As String In
>My.Computer.FileSystem.GetFiles(curdir & "\_res_original", _
>            FileIO.SearchOption.SearchAllSubDirectories, TextBox1.Text)
>                My.Computer.FileSystem.DeleteFile(foundFile)
>            Next
>        End If
>
>------------
>
>TextBox1.Text should look like <"*.exe", "*.txt", "*.ini">
>It works with one extension but if I specify many of them, vb gives an error
>that there is an illegal character. I suppose it handles the commas not
>correctly.
>
>Thanks for any help


The argument for wildcard parameters is a string array:
Dim FileTypes As String() = {"*.exe", "*.txt", "*.ini"}

Change ....SearchAllSubDirectories, TextBox1.Text
to
.....SearchAllSubDirectories, FileTypes


Gene
Author
25 Aug 2006 10:12 AM
kenny
Thanks.
But how can I convert the string from the textbox into a string array so it
will be recognized as separated wildcards?

"gene kelley" schrieb:
Show quoteHide quote
>
>
> The argument for wildcard parameters is a string array:
> Dim FileTypes As String() = {"*.exe", "*.txt", "*.ini"}
>
> Change ....SearchAllSubDirectories, TextBox1.Text
> to
> .....SearchAllSubDirectories, FileTypes
>
>
> Gene
>
Author
25 Aug 2006 12:26 PM
Peter Proost
This returns a string array:

TextBox1.Text.split(","c)

hope this helps

Greetz, Peter




--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Show quoteHide quote
"kenny" <ke***@discussions.microsoft.com> schreef in bericht
news:7C06D9A4-F73D-4BE0-8E0E-5CFF7A54C875@microsoft.com...
> Thanks.
> But how can I convert the string from the textbox into a string array so
it
> will be recognized as separated wildcards?
>
> "gene kelley" schrieb:
> >
> >
> > The argument for wildcard parameters is a string array:
> > Dim FileTypes As String() = {"*.exe", "*.txt", "*.ini"}
> >
> > Change ....SearchAllSubDirectories, TextBox1.Text
> > to
> > .....SearchAllSubDirectories, FileTypes
> >
> >
> > Gene
> >
Author
25 Aug 2006 12:56 PM
kenny
Alright, it works.
I forgot to write the c, that was the problem.
Thank you both for helping me!

"Peter Proost" schrieb:

Show quoteHide quote
> This returns a string array:
>
> TextBox1.Text.split(","c)
>
> hope this helps
>
> Greetz, Peter
>
>
>
>
> --
> Programming today is a race between software engineers striving to build
> bigger and better idiot-proof programs, and the Universe trying to produce
> bigger and better idiots. So far, the Universe is winning. (Rich Cook)
>
> "kenny" <ke***@discussions.microsoft.com> schreef in bericht
> news:7C06D9A4-F73D-4BE0-8E0E-5CFF7A54C875@microsoft.com...
> > Thanks.
> > But how can I convert the string from the textbox into a string array so
> it
> > will be recognized as separated wildcards?
> >
> > "gene kelley" schrieb:
> > >
> > >
> > > The argument for wildcard parameters is a string array:
> > > Dim FileTypes As String() = {"*.exe", "*.txt", "*.ini"}
> > >
> > > Change ....SearchAllSubDirectories, TextBox1.Text
> > > to
> > > .....SearchAllSubDirectories, FileTypes
> > >
> > >
> > > Gene
> > >
>
>
>
Author
25 Aug 2006 1:28 PM
Peter Proost
You're welcome

Greetz, Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Show quoteHide quote
"kenny" <ke***@discussions.microsoft.com> schreef in bericht
news:8CE11163-343F-4604-8E43-A8B884B2401D@microsoft.com...
> Alright, it works.
> I forgot to write the c, that was the problem.
> Thank you both for helping me!
>
> "Peter Proost" schrieb:
>
> > This returns a string array:
> >
> > TextBox1.Text.split(","c)
> >
> > hope this helps
> >
> > Greetz, Peter
> >
> >
> >
> >
> > --
> > Programming today is a race between software engineers striving to build
> > bigger and better idiot-proof programs, and the Universe trying to
produce
> > bigger and better idiots. So far, the Universe is winning. (Rich Cook)
> >
> > "kenny" <ke***@discussions.microsoft.com> schreef in bericht
> > news:7C06D9A4-F73D-4BE0-8E0E-5CFF7A54C875@microsoft.com...
> > > Thanks.
> > > But how can I convert the string from the textbox into a string array
so
> > it
> > > will be recognized as separated wildcards?
> > >
> > > "gene kelley" schrieb:
> > > >
> > > >
> > > > The argument for wildcard parameters is a string array:
> > > > Dim FileTypes As String() = {"*.exe", "*.txt", "*.ini"}
> > > >
> > > > Change ....SearchAllSubDirectories, TextBox1.Text
> > > > to
> > > > .....SearchAllSubDirectories, FileTypes
> > > >
> > > >
> > > > Gene
> > > >
> >
> >
> >