Reputation: 4665
There is a one folder located in a directory, lets say its in
C:\Users\User\AppData\Roaming\Mozilla\Firefox\Profiles\
it's different on everyuser, for example 1rituum9.default named folder.
Tried this without any luck, it messages empty.
Dim filepath As String = "%Appdata%\Mozilla\Firefox\Profiles\"
Dim fi As New IO.FileInfo(filepath)
MessageBox.Show(fi.Name)
What is the correct way to get the folder name in specified directory ?
Upvotes: 0
Views: 3268
Reputation: 225
You can try this:
Dim filepath As String = Environment.GetEnvironmentVariable("appdata") & "\Mozilla\Firefox\Profiles\"
Dim di As New IO.DirectoryInfo(filepath)
MessageBox.Show(di.GetDirectories()(0).Name)
if there are more than one dirs u might need something like:
For Each Dir As IO.DirectoryInfo In di.GetDirectories()
ListBox1.Items.Add(Dir)
Next
Edit: Fixed Code Line 1 - see comments
Upvotes: 2