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

运行结果:

相关推荐
Yupureki19 分钟前
《Linux系统编程》12.基础IO
linux·运维·c语言·开发语言·数据库·c++
淮北49419 分钟前
bash下好用的快捷键以及linux常用指令
linux·开发语言·ubuntu·bash
薛定谔的猫喵喵37 分钟前
卸载 Python 3.8 报错 “Could not set file security” 的终极解决方案
开发语言·python
看山是山_Lau1 小时前
代码命名规范原则与原理
c语言·开发语言
_MyFavorite_1 小时前
JAVA重点基础、进阶知识及易错点总结(8)List 接口(ArrayList、LinkedList、Vector)
java·开发语言·list
第二层皮-合肥1 小时前
基于C#的工业测控软件-依赖库
java·开发语言
橘子131 小时前
C++11 lambda表达式
开发语言·c++
2401_857918291 小时前
分布式系统安全通信
开发语言·c++·算法
C^h1 小时前
RTthread消息队列学习
开发语言·算法·嵌入式