C# 路径操作

一、打开程序所在路径

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";

运行结果:

相关推荐
咩咩觉主2 分钟前
Unity实战案例全解析:PVZ 植物卡片状态分析
unity·c#·游戏引擎
好兄弟给我起把狙4 分钟前
[Golang] Select
开发语言·后端·golang
Echo_Lee06 分钟前
C#与Python脚本使用共享内存通信
开发语言·python·c#
python之行16 分钟前
python 环境问题
开发语言·python
小林熬夜学编程17 分钟前
C++第五十一弹---IO流实战:高效文件读写与格式化输出
c语言·开发语言·c++·算法
不是编程家29 分钟前
C++ 第三讲:内存管理
java·开发语言·c++
hakesashou32 分钟前
python怎么写csv文件
开发语言·python
欧阳枫落36 分钟前
pip 换源
开发语言·python·pip
学步_技术1 小时前
Python编码系列—Python组合模式:构建灵活的对象组合
开发语言·python·组合模式
o独酌o2 小时前
递归的‘浅’理解
java·开发语言