Results 1 to 5 of 5

Thread: Distrition of a vb 2019 applicazione

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Distrition of a vb 2019 applicazione

    In VB 2019 i created a little application using Add Windows Form. To read an external text file I had to say the path where it was, for example "c:\users\myname\desktop\text.txt". So far no problem. It works and read my file assigning it to a RichTextBox.
    The question is: if i distribute the app to work on other computer it will always point to the address I wrote in the code but on the other computer it may not be that path.
    How to solve? Have I to tell whoever receives the application to create a directory with the same name and insert there the file? Or it is possible to do otherwise.
    Thanks in advance.

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    715

    Re: Distrition of a vb 2019 applicazione

    You need to use an openfiledialog object, so you can go to look for your file where you want : https://docs.microsoft.com/en-us/dot...g?view=net-5.0
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  3. #3
    Addicted Member
    Join Date
    Jul 2017
    Location
    Exeter, UK
    Posts
    152

    Re: Distrition of a vb 2019 applicazione

    Take a look at the Application Class documentation which will provide paths specific to the application and user folder e.g.if you place the text file in the same folder as the executable you can use Application.StartupPath property, to get the folder name which you use when opening the file. https://docs.microsoft.com/en-us/dot...h?view=net-5.0
    Last edited by bmwpete; Sep 9th, 2021 at 10:21 AM. Reason: grammer

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,634

    Re: Distrition of a vb 2019 applicazione

    If you specifically want to read the file from the desktop then you can use code that will resolve the desktop folder every time:
    vb.net Code:
    1. Dim filePath = Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "text.txt")
    Now you can just tell all users to put a file with that name on their desktop. If you want to be able to read the file from anywhere, do as suggested by Delaney above.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    12

    Re: Distrition of a vb 2019 applicazione

    thank you very much

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