maky55 maky55 - 3 months ago 19 Question

Finding a folder

I'm making a windows form application, and I want to create a check for a folder, which I know how to do, but I don't want it to be

"C:\Users\User\Documents\Visual Studio 2015\Projects\This Project\Required Files\file.txt"


"This Project\Required Files\file.txt"

is that possible?
I need to do this because I want to app to be portable, and if I put the whole path starting with C and the app is installed somewhere else (For EG. C:\User\Bob\Application\Required Files\file.txt")


You can do something like. For example you a folder the has 2 sub-folders

1.My Program

2.Required Files

The folder My Program contains your program .exe for example

and the folder Required Files has the files.txt

you can do something like this in your code.

Dim path as string = App.Path & "\Required Files\file.txt"

so what will happen is that whereever your program will installed the Required File folder will follow. The App.Path will create the rest of the folder location + the assigned folder that you have and that is "\Required Files\file.txt"

See? Relationship goals hahaha kidding.

I didnt see that you have another folder called Project you just do this.

Dim path as string = App.Path & "Project\Required Files\file.txt"

I hope this one helps.