none
get app path befor setup in vb.net RRS feed

  • Question

  • I want to bring the program path before the set up by code

    how to get the path  before the set up  - any folder found the app in it


    a dont want the path  after the set up     MsgBox(Application.StartupPath)

    a dont want                        =====>  c:\program files 86 \ program name


    Tuesday, February 13, 2018 7:03 PM

Answers

  • I want to bring the program path before the set up by code

    how to get the path  before the set up  - any folder found the app in it


    a dont want the path  after the set up     MsgBox(Application.StartupPath)

    a dont want                        =====>  c:\program files 86 \ program name


    Hi monemas,

    Do you want to get executable directory where application is running from? If yes, you can use the following code:

    Dim strPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
            Console.WriteLine(strPath)

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by monemas Thursday, February 15, 2018 12:48 AM
    Wednesday, February 14, 2018 5:56 AM
    Moderator
  • I'm not sure what you mean. If you do not programatically set the current working path then the apps startup path is the current working path. Below code sets the desktop folder as the apps working path. You could set the working path to anything valid but if the path is protected and requires admin privileges the app will have to run appropriately with admin privileges.

    Environment.CurrentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
    MessageBox.Show(Environment.CurrentDirectory)



    La vida loca

    • Edited by Mr. Monkeyboy Wednesday, February 14, 2018 7:39 AM
    • Marked as answer by monemas Thursday, February 15, 2018 12:48 AM
    Wednesday, February 14, 2018 7:36 AM

All replies

  • I want to bring the program path before the set up by code

    I can't quite work out which portion you do want and which portion you don't want, but the methods of the Path object allow you to extract pretty much any required portion. See:
    https://msdn.microsoft.com/en-us/library/system.io.path%28v=vs.110%29.aspx

    Tuesday, February 13, 2018 8:25 PM
  • I want to bring the program path before the set up by code

    how to get the path  before the set up  - any folder found the app in it


    a dont want the path  after the set up     MsgBox(Application.StartupPath)

    a dont want                        =====>  c:\program files 86 \ program name


    Hi monemas,

    Do you want to get executable directory where application is running from? If yes, you can use the following code:

    Dim strPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase)
            Console.WriteLine(strPath)

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by monemas Thursday, February 15, 2018 12:48 AM
    Wednesday, February 14, 2018 5:56 AM
    Moderator
  • I'm not sure what you mean. If you do not programatically set the current working path then the apps startup path is the current working path. Below code sets the desktop folder as the apps working path. You could set the working path to anything valid but if the path is protected and requires admin privileges the app will have to run appropriately with admin privileges.

    Environment.CurrentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
    MessageBox.Show(Environment.CurrentDirectory)



    La vida loca

    • Edited by Mr. Monkeyboy Wednesday, February 14, 2018 7:39 AM
    • Marked as answer by monemas Thursday, February 15, 2018 12:48 AM
    Wednesday, February 14, 2018 7:36 AM