Reputation: 11
My program (Visual Basic 2010) has to run on different people's machines, so I have to use a relative path like %appdata%, but I also have to get a file from a randomly named directory. its like this:
C:\Users\Administrator\AppData\Roaming\Dir1\Dir2\Dir3\Random-NameDir\file
Also, the randomly named directory is the only one in Dir3. (BTW im trying to get the filepath)
I can use this, but it does not get through the random directory (and i cant find a way to search with the environment class there)
Dim a As New Attachment(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Dir1\Dir2\Dir3")
And when i try this,
For Each foundFile As String In My.Computer.FileSystem.GetFiles( _
My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData & "\Dir1\Dir2\Dir3", _
FileIO.SearchOption.SearchAllSubDirectories, "MyFile.ext")
ListBox1.Items.Add(foundFile)
Next
AppData sends me to WindowsApplicaiton1\1.0.0 somthing which is a folder in appdata\roaming.
Basically my question is, Can I search for a file, limiting the search to only the randomly named directory (which is in application data), in order to get the file path that I can then use as an attachment for an email?
Upvotes: 1
Views: 1037