相对路径
当前程序的所在目录
textBox1.Text = AppDomain.CurrentDomain.BaseDirectory;
返回
D:\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\
当前程序的完整路径
textBox1.Text = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
D:\Administrator\Desktop\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
获取程序文件名 (无扩展名)
textBox1.Text = System.IO.Path.GetFileNameWithoutExtension(@"C:\cmd.exe");
返回 cmd

浙公网安备 33010602011771号