Results 1 to 6 of 6

Thread: How to set a path

  1. #1

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Resolved 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.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  3. #3

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    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

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member jokerfool's Avatar
    Join Date
    Dec 2006
    Location
    Gold Coast, Australia
    Posts
    452

    Re: How to set a path

    Its not answered wow, I dont know how to do what they mentioned.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width