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

运行结果:

相关推荐
爱吃山竹的大肚肚1 小时前
在Java中,从List A中找出List B没有的数据(即求差集)
开发语言·windows·python
weixin_462446231 小时前
【原创实践】Python 将 Markdown 文件转换为 Word(docx)完整实现
开发语言·python·word
企微自动化1 小时前
企业微信二次开发:深度解析外部群主动推送的实现路径
java·开发语言·企业微信
我的offer在哪里1 小时前
c++的回调函数
开发语言·c++
一棵开花的树,枝芽无限靠近你1 小时前
【face-api.js】2️⃣ NetInput - 神经网络输入封装类
开发语言·javascript·神经网络
yongche_shi1 小时前
第九十九篇:Python在其他领域的应用:游戏开发、物联网、AIoT简介
开发语言·python·物联网·游戏开发·aiot
froginwe111 小时前
Node.js 回调函数
开发语言
期待のcode1 小时前
Java中的继承
java·开发语言
资深低代码开发平台专家1 小时前
MicroQuickJS:为极致资源而生的嵌入式JavaScript革命
开发语言·javascript·ecmascript
世转神风-1 小时前
qt-通信协议基础-固定长度-小端字节序补0x00指导
开发语言·qt