|
-
Oct 29th, 2019, 08:27 AM
#1
Thread Starter
Hyperactive Member
How to set a path
If I have a file that I constantly access in the root of either C or D, how can I have a button that allows me to choose the path, remembers the path, so when I click the link in the menu, that file actually opens?
Thank you.
Last edited by jokerfool; Nov 13th, 2019 at 07:53 PM.
-
Oct 29th, 2019, 10:06 AM
#2
Re: How to set a path
You can use an OpenFileDialog to allow the user to select the location (you could use a FolderBrowserDialog instead, but a File one helps the user check that the location is valid).
Once the location is selected, save that data (which is just a String containing the path) to wherever is appropriate for your app. Valid options include a database (but only if you are using one already for other purposes), in Settings, or a file, or possibly the Registry (but that is usually not wise).
When your app wants to know the location (to open the file etc), read the data that was saved.
By the way it isn't a great idea to store files in the root of a drive (it causes a variety of issues that are usually minor), it is better to store in a more appropriate location instead - which might be the users Documents folder, or perhaps in AppData or ProgramData etc.
-
Oct 29th, 2019, 10:18 AM
#3
Thread Starter
Hyperactive Member
Re: How to set a path
I've been storing the files in the root directory for the last 7 years with this software, cheers si
-
Oct 29th, 2019, 05:14 PM
#4
Re: How to set a path
If your issue is resolved then please use the Thread Tools menu to mark the thread Resolved. That way we don't have to open the thread and read the whole thing to find out that you don't need help any more.
-
Oct 29th, 2019, 07:15 PM
#5
Thread Starter
Hyperactive Member
Re: How to set a path
Its not answered wow, I dont know how to do what they mentioned.
-
Oct 29th, 2019, 08:13 PM
#6
Re: How to set a path
I interpreted "cheers si" as "thinks for the solution". I guess it wasn't.
So what's the problem then? I see no indication that you've tried to do anything. Using an OpenFileDialog is not hard and it's not hard to find information on how to do it. What have you done and where are you stuck?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|