如何获得我的项目路径? [英] How to get my project path?

查看:70
本文介绍了如何获得我的项目路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
使用c#为我的.exe获取路径

Possible Duplicate:
get path for my .exe using c#

你好,我有一个问题: 如何获得我的根项目路径?我的意思是解决方案在项目中的第一个文件夹. 我找到了该命令:

Hello I have a question: How can I get my root project path? what I mean is the first folder in the project where the solution is. I found that command :

System.IO.Directory.GetCurrentDirectory();

但是,它为我提供了发行文件夹的特定路径: wanted_Path/bin/Release

However it gives me a specific path to the release folder: wanted_Path/bin/Release

还有其他代码,我应该手动剪切还是将文件放在Release文件夹中?

So is there other code, should I cut it manually or put my files in the Release folder??

推荐答案

您可以使用

string wanted_path = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));

这篇关于如何获得我的项目路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆