I am building an application that opens all kinds of files from different folders. I need to open the application by subsequently opening a Powerpoint presentation which has "1" at the beginning of its name. How should I do this? I wrote the following code but it works only if I put in the exact name:
If (System.IO.File.Exists("FilePath\1*")) Then
'Lists File Names from folder & when selected, opens selected file in default program
Dim file3dopen As New ProcessStartInfo()
With file3dopen
.FileName = "TheFilepath\1*"
.UseShellExecute = True
End With
Process.Start(file3dopen)
Else
MsgBox("No Such File Exists")
End If
You need to look for all the files in that directory using Directory.GetFiles(string path, string pattern)
.
Dim files As String() = Directory.GetFiles("\FilePath", "1*")
If files.Length > 0 Then ' file found
Dim file3dopen As New ProcessStartInfo()
With file3dopen
.FileName = files(0)
.UseShellExecute = True
End With
Process.Start(file3dopen)
Else
'file not found
MsgBox("No Such File Exists")
End If