Wildcards?

zhughes

Member
Joined
Feb 15, 2008
Messages
15
Programming Experience
Beginner
Should be fairly simple.... I basically want to find a specific folder on multiple machines.
Here's what I have so far:

Dim UserName As String = Environment.UserName
System.Diagnostics.Process.Start("C:\Documents and Settings\" & UserName & "\Local Settings\Temporary Internet Files\OLK###")

The OLK### folder is different on every machine. OLK stays consistant, with the numbers varying.

How can I open this folder using wildcards or something similar?

Thanks!
 
I'm not to sure how you would implement this but have you considered the possibility that your code could result in an error based on there being a case where two or more files/folder contain similar names?
 
I'm not worried about multiple folders - if that happens I can figure out some error handling code. I basically want to open a folder begginning with "OLK"
 
VB.NET:
Dim folders As String() = IO.Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache), _
                                                                                "OLK*")

If folders.Length = 0 Then
    MessageBox.Show("There are no Internet cache folders starting with ""OLK"".")
Else
    For Each folder As String In folders
        Process.Start(folder)
    Next folder
End If
It is generally a very bad idea to hard-code paths as you have. There are all sorts of reasons that the path could be invalid, e.g. Windows was not installed on the C: drive or the Windows version uses a different path. As an example of that second condition, your path might be valid on XP but it definitely wouldn't on Vista.
 
This topic has nothing whatsoever to do with Windows Forms so it doesn't belong in the Windows Forms forum. If you were knitting in a car you wouldn't ask a question about it on an automotive forum. Whether or not yours is a WinForms app, this question is not WinForms-related. Moved.
 
Ok, thanks for your post!

One more thing on this topic.

How can I find this folder & delete all files in it?

Thanks ahead of time!
 
Back
Top