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

运行结果:

相关推荐
时空系23 分钟前
第10篇:继承扩展——面向对象编程进阶 python中文编程
开发语言·python·ai编程
CHANG_THE_WORLD2 小时前
python 批量终止进程exe
开发语言·python
古城小栈2 小时前
从 cargo-whero 库中,找到提升 rust 的契机
开发语言·后端·rust
Gary Studio3 小时前
安卓HAL C++基础-智能指针
开发语言·c++
啧不应该啊3 小时前
Day1 Python 与 C 的类型区别
c语言·开发语言
cen__y3 小时前
Linux07(信号01)
linux·运维·服务器·c语言·开发语言
xingpanvip4 小时前
星盘接口开发文档:星相日历接口指南
android·开发语言·前端·css·php·lua
guygg884 小时前
基于遗传算法的双层规划模型求解MATLAB实现
开发语言·matlab
凯瑟琳.奥古斯特4 小时前
SQLAlchemy核心功能解析
开发语言·python·flask
卷Java4 小时前
GPTQ vs AWQ vs GGUF:模型量化工具横向测评
开发语言·windows·python