一、打开程序所在路径
cs
try
{
string debugPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
System.Diagnostics.Process.Start(debugPath);
}
catch (Exception ex)
{
MessageBox.Show("无法打开目录:" + ex.Message);
}
运行结果:
二、获取程序所在路径下指定文件路径
cs
string debugPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
debugPath = debugPath + "\\测试模板.csv";
运行结果: