2014-09-11 225 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(); 
相關問題