2014-09-11 226 views
1

在我的项目中,我添加了一个包含文件的文件夹。他们都有本地的道路。如何获取我的项目中文件夹的路径(以及该文件夹中文件的路径)?

我想要一个字符串数组,所有这些文件的路径,但我不知道如何做到这一点。

我试过这个,但它只返回格式为“namespace + project + foldername + name”的字符串。

string[] test = Assembly.GetExecutingAssembly().GetManifestResourceNames(); 

我要的是完整的路径:

d:\项目名\项目\文件夹\ file.ext

这也将有助于得到参考/路径该文件夹,因为那么我可以得到的文件:

System.IO.Directory.GetFiles(); 

任何人都有想法?

+0

字符串测试= System.AppDomain.CurrentDomain.BaseDirectory;做好了。在这里找到:http://stackoverflow.com/questions/14549766/how-to-get-my-project-path – user3616874 2014-09-11 13:34:13

回答

0

试试这个。

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

试试这个

string[] files= Directory.GetFiles(@"directory"); 

,如果你想使你的项目目录使用

string path = Directory.GetCurrentDirectory(); 
相关问题