Get path to execution directory of Windows Forms application

前端 未结 8 620
一个人的身影
一个人的身影 2020-11-29 04:47

I would like to get the path to the execution directory of a Windows Forms application. (That is, the directory in which the executable is located.)

Does anyone know

相关标签:
8条回答
  • 2020-11-29 05:43

    Both of the examples are in VB.NET.

    Debug path:

    TextBox1.Text = My.Application.Info.DirectoryPath
    

    EXE path:

    TextBox2.Text = IO.Path.GetFullPath(Application.ExecutablePath)
    
    0 讨论(0)
  • 2020-11-29 05:47

    Application.Current results in an appdomain http://msdn.microsoft.com/en-us/library/system.appdomain_members.aspx

    Also this should give you the location of the assembly

    AppDomain.CurrentDomain.BaseDirectory
    

    I seem to recall there being multiple ways of getting the location of the application. but this one worked for me in the past atleast (it's been a while since i've done winforms programming :/)

    0 讨论(0)
提交回复
热议问题