Determine if exist in unknown folder

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
6 posts Page 1 of 1
Contributors
User avatar
Rhez
Member
Member
Posts: 30
Joined: Sat Jan 04, 2014 7:24 am

Determine if exist in unknown folder
Rhez
Hello again boogy;

Got some problem and I dunno how to do it.

I want to check if a file from unknown folder exist idoit;
for example: I want to check a save_settings.dll in a user created folder "User"

Account/User/save_settings.dll

Account is the root folder
User will be the folder (unknown folder cause this may change depend on user input)
save_settings.dll the file to be check if exist.

location may vary depends on user input:
other example

Account/MyDog/save_settings.dll
Account/CoolApps/save_settings.dll

I hope you gets my problem blusho;
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Code: Select all
If My.Computer.FileSystem.FileExists("Account\" + user_created_folder + "\save_settings.dll") Then
    MessageBox.Show("The file exists!")
Else
    MessageBox.show("The file does not exist!")
End If
user_created_folder is a String that represents the user created.
User avatar
Rhez
Member
Member
Posts: 30
Joined: Sat Jan 04, 2014 7:24 am

No. My Project is separated to its main application.
To make it easy to understand. The one project will create user profile. The other project will check for file existence
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Right... so this should work
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

You could use this code to list the user folders and check for the file:
Code: Select all
        Dim users As String() = IO.Directory.GetDirectories("Account")

        For Each user In users

            Dim path As String = user & "\save_settings.dll"
            If IO.File.Exists(path) Then
                MsgBox("found " & path)

            End If

        Next
User avatar
Rhez
Member
Member
Posts: 30
Joined: Sat Jan 04, 2014 7:24 am

Hello mandai. Gonna try yours. Seems like this one is what I'm looking for boogy;
6 posts Page 1 of 1
Return to “Coding Help & Support”