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

运行结果:

相关推荐
xxjj998a7 小时前
Laravel3.x:奠定现代PHP框架的重要里程碑
android·开发语言·php
(Charon)8 小时前
【C++/Qt】Qt 实现 MQTT 测试工具:连接 Broker、订阅主题与发布消息
开发语言·c++·qt
Ulyanov8 小时前
《现代 Python 桌面应用架构实战:PySide6 + QML 从入门到工程化》:动态数据仪表盘与 NumPy 可视化 —— 从标量到向量的数据驱动进化
开发语言·python·qt·架构·numpy
小短腿的代码世界8 小时前
Qt序列化与持久化深度解析:从QDataStream到自定义二进制协议
开发语言·数据库·qt
周末也要写八哥8 小时前
Golang语言与Rust语言的对比
开发语言·后端·golang
楼田莉子8 小时前
Linux网络:数据链路层
linux·服务器·开发语言·网络·c++·后端
不甘先生8 小时前
Go 四层架构实战:Handler + Service + Repository + Entity(清晰、可控、可演进)
开发语言·架构·golang
Yang-Never8 小时前
Git -> Git Worktree 工作树
android·开发语言·git·android studio
riNt PTIP8 小时前
GO 快速升级Go版本
开发语言·redis·golang
xingpanvip8 小时前
星盘接口开发文档:日运语料接口指南
android·开发语言·前端·css·php·lua