2013-03-07 73 views
0

我正在處理一個c#項目,並試圖獲取我的可執行文件運行的位置的當前路徑。但是,我正在使用的方法是將file:\\添加到開頭,即file:\\C:\\users\\user\\Project\\Debug所有我想要的字符串是C:\\users\\user\\Project\\Debug但我找不到一種方法來執行此操作。如何獲得沒有文件的路徑:\在開始處

下面是我使用

string basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); 

感謝代碼任何幫助,您可以提供

回答

4
string basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 
1
var basePath = AppDomain.CurrentDomain.BaseDirectory; 
相關問題