Get path to execution directory of Windows Forms application

前端 未结 8 662
一个人的身影
一个人的身影 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:33

    Private Sub Main_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Dim args() As String = Environment.GetCommandLineArgs()
        If args.Length > 0 Then
            TextBox1.Text = Path.GetFullPath(Application.ExecutablePath)
            Process.Start(TextBox1.Text)   
        End If
    End Sub
    

提交回复
热议问题