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

运行结果:

相关推荐
anqi2716 分钟前
如何在 IntelliJ IDEA 中编写 Speak 程序
java·大数据·开发语言·spark·intellij-idea
XuX0321 分钟前
MATLAB小试牛刀系列(1)
开发语言·matlab
Suckerbin31 分钟前
第十四章-PHP与HTTP协议
开发语言·http·php
Best_Liu~37 分钟前
TransactionTemplate 与@Transactional 注解的使用
java·开发语言·spring boot·后端
谈不譚网安42 分钟前
初识Python
开发语言·python
慕雪华年1 小时前
【Python】使用uv管理python虚拟环境
开发语言·python·ai·uv·mcp
狗蛋儿l1 小时前
qt 3d航迹图
开发语言·qt·3d
学习机器不会机器学习2 小时前
深入浅出JavaScript常见设计模式:从原理到实战(2)
开发语言·javascript·设计模式
阿方.9182 小时前
C语言----操作符详解(万字详解)
c语言·开发语言
学渣676562 小时前
conda和bash主环境的清理
开发语言·conda·bash