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

运行结果:

相关推荐
weixin_440730502 小时前
函数return、参数、参数组、递归函数、高阶函数等小结
开发语言·python
sugarzhangnotes2 小时前
【无标题】
开发语言·人工智能·python
geovindu2 小时前
rust: Composite Pattern
开发语言·后端·设计模式·rust·组合模式
samble2 小时前
从零搭建灌装监控系统(十):生产追溯,条码触发自动记录
c#·wpf·mvvm·modbus·工业控制
周杰偷奶茶3 小时前
【Java】数组的定义和使用(附管理系统实战案例)
java·开发语言
橙子圆1234 小时前
JUC之集合类不安全
java·开发语言
阿里嘎多学长4 小时前
2026-09-29 GitHub 热点项目精选
开发语言·程序员·github·代码托管
Bruce_Liuxiaowei4 小时前
网页版 DeepSeek “harness desktop“ WebGL 上下文创建失败排查实录
开发语言·javascript·webgl
狗凯之家源码网4 小时前
PHP 用户反馈系统源码深度评测与实战指南
开发语言·php·用户反馈系统
谢亮_vipxieliang5 小时前
Stream API 不是银弹:常见坑与性能建议
java·开发语言