VB.net 相對路徑
Imports System.Reflection
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'~~~相對路徑
Debug.WriteLine(Assembly.GetEntryAssembly.Location)
Debug.WriteLine(Me.GetType().Assembly.Location) '我常用
Debug.WriteLine(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)
Debug.WriteLine(System.Environment.CurrentDirectory)
Debug.WriteLine(System.AppDomain.CurrentDomain.BaseDirectory)
Debug.WriteLine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase)
Debug.WriteLine(System.Windows.Forms.Application.StartupPath)
Debug.WriteLine(System.Windows.Forms.Application.StartupPath)
Debug.WriteLine(System.Windows.Forms.Application.ExecutablePath)
Debug.WriteLine(System.IO.Directory.GetCurrentDirectory)
'~~~
'P.S 得到的路徑加上 \.. 可以返回上層位置
End Sub
End Class