Visual Basic.net Does a file exist using wildcards

Visual Basic.net Does a file exist using wildcards

isocam
Collaborator Collaborator
1,749 Views
2 Replies
Message 1 of 3

Visual Basic.net Does a file exist using wildcards

isocam
Collaborator
Collaborator
Can anybody help?

I am writing a visual basic.net application and I need to see if any files exist with a "*.tmp" filename

Simply...

I have created a directory and I put all my temp files in there. I need to know if any "*.tmp" files exist before i delete (kill) them.

I also need to find if any files exist with the wildcard name "sometext*.tmp"

can anybody help??

any thanks in advance

IsoCAM
0 Likes
1,750 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Perhaps something like this?

 

Joe ...

 

 



size=2>With

color=#0000ff size=2>My
.Computer.FileSystem


 
If
.FileExists(
size=2>"C:\*.tmp"
)

size=2>Then


 
End

color=#0000ff size=2>If



size=2>End

color=#0000ff size=2>With



size=2>
 



color=#000000>
 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Can
anybody help? I am writing a visual basic.net application and I need to see if
any files exist with a "*.tmp" filename Simply... I have created a directory
and I put all my temp files in there. I need to know if any "*.tmp" files
exist before i delete (kill) them. I also need to find if any files exist with
the wildcard name "sometext*.tmp" can anybody help?? any thanks in advance
IsoCAM
0 Likes
Message 3 of 3

Anonymous
Not applicable

Sorry, that last post will not work. Here is
one that does, however.

 

Joe ...

 

 

Imports System.IO

 

Module Module1

 

    Sub
Main()
        Dim File As
String

 

        For Each
File In Directory.GetFiles("C:\", "*.tmp")

       
    '<--- do you thing here --->'

        Next
File

 

    End Sub

 

End Module

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">


Perhaps something like this?

 

Joe ...

 

 



size=2>With

color=#0000ff size=2>My
.Computer.FileSystem


 
If
.FileExists(
size=2>"C:\*.tmp"
)

size=2>Then


 
End

color=#0000ff size=2>If



size=2>End

color=#0000ff size=2>With



size=2>
 



color=#000000>
 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Can
anybody help? I am writing a visual basic.net application and I need to see
if any files exist with a "*.tmp" filename Simply... I have created a
directory and I put all my temp files in there. I need to know if any
"*.tmp" files exist before i delete (kill) them. I also need to find if any
files exist with the wildcard name "sometext*.tmp" can anybody help?? any
thanks in advance IsoCAM
0 Likes