无法获取C#应用程序中存在的文件夹的完整路径 [英] Could not get the full path of folder present in C # Application

查看:202
本文介绍了无法获取C#应用程序中存在的文件夹的完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用c#创建了一个Windows应用程序.
我在其中创建了一个文件夹(即folder1).在该文件夹(即folder1)中,我添加了文本文件(即TextFile1).

现在我必须在某个字符串变量中获取此文件的路径,即TextFile1.

如何获得正确的路径?请帮忙.

我的exe位于bin \ debug文件夹中.但是folder1在bin文件夹之外.

在此先感谢您.

解决方案

您的应用程序EXE驻留在哪里?
如果它位于"folder1"级别.那么你可以得到它

 Application.ExecutablePath + "  


 字符串 strRootDir = System.IO.
Directory.GetCurrentDirectory();
字符串 strPath = strRootDir + " ; 




如果解决您的问题,请标记为答案.


 Application.ExecutablePath + "  .. \ .. \ Folder1 \ Textfile1.txt" < /  pre  >  


I Have created one windows application in c#.
i have created one folder in it (i.e. folder1). In that folder (i.e folder1) i have added text file (i.e. TextFile1).

Now i have to get the path of this file i.e TextFile1 in some string variable.

How can it possible to get correct path? Please help.

my exe is in bin\debug folder. but folder1 is outside bin folder.

Thanks in advance.

解决方案

Where is your application EXE reside ?
if it reside at "folder1" level. then you can get it like

Application.ExecutablePath + "\Folder1\Textfile1.txt"


string strRootDir = System.IO.
Directory.GetCurrentDirectory();
string strPath = strRootDir + "\\Folder1\\TextFile1.txt";




mark as answer if solves your problem.


Application.ExecutablePath + "..\..\Folder1\Textfile1.txt"<</pre>


这篇关于无法获取C#应用程序中存在的文件夹的完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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