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

运行结果:

相关推荐
「QT(C++)开发工程师」14 分钟前
C++ 11 常用for循环
开发语言·c++
我还记得那天24 分钟前
0 初识C++
开发语言·c++
FfHUCisI1 小时前
Go 编译过程全景
开发语言·后端·golang
FfHUCisI1 小时前
Golang 语法分析与 AST:Parser 与 go/ast
开发语言·后端·golang
lemon_sjdk2 小时前
ObjectProperty
java·开发语言·算法
大模型码小白2 小时前
Spring AI Tool 实现自然语言操作 MySQL 数据库详解
服务器·开发语言·数据库·人工智能·python·mysql·spring
hh9502 小时前
Agent Plan x DeepSeek Harness:Agent 供应链安全与第三方插件审计
java·开发语言·安全·agent plan·adg成都社区·adg社区
Behaviour2 小时前
Unity UI循环列表UIScrollViewContent实现
ui·unity·c#·游戏引擎
「QT(C++)开发工程师」2 小时前
C++ std::move 详解
开发语言·c++