2016-08-02 60 views
0

我想引用我的項目資源文件夾作爲路徑。 如果我使用越來越獲取項目資源文件夾路徑

string filePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString(); 

結果作爲

"C:\\MYDEV\\MyProject\\bin\\Debug" 

我怎樣才能得到 「C:\\MYDEV\\MyProject\\Resources」?

+0

會嵌入的資源是你正在找? https://support.microsoft.com/en-gb/kb/319292 – LeBaptiste

回答

0

首先,你可以得到項目中使用的文件夾:

var projectPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; 

,然後就用你的資源文件夾結合起來

string filePath = Path.Combine(projectPath, "Resources"); 

string filePath = Path.Combine(System.IO.Path.GetFullPath(@"..\..\"), "Resources"); 
相關問題