第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在.NET控制臺應(yīng)用程序中獲取應(yīng)用程序的路徑?

如何在.NET控制臺應(yīng)用程序中獲取應(yīng)用程序的路徑?

至尊寶的傳說 2019-06-05 16:12:36
如何在.NET控制臺應(yīng)用程序中獲取應(yīng)用程序的路徑?如何在控制臺應(yīng)用程序中找到應(yīng)用程序的路徑?在……里面Windows窗體,我可以用Application.StartupPath若要查找當前路徑,但這在控制臺應(yīng)用程序中似乎不可用。
查看完整描述

3 回答

?
素胚勾勒不出你

TA貢獻1827條經(jīng)驗 獲得超9個贊

System.Reflection.Assembly.GetExecutingAssembly().Location1

把它和System.IO.Path.GetDirectoryName如果你想要的只是目錄。

1根據(jù)Mindor先生的評論:
System.Reflection.Assembly.GetExecutingAssembly().Location返回當前正在執(zhí)行的程序集所在的位置,在不執(zhí)行時,該位置可能是也可能不是程序集所在的位置。在影子復(fù)制程序集的情況下,您將在臨時目錄中獲得一個路徑。System.Reflection.Assembly.GetExecutingAssembly().CodeBase將返回程序集的“永久”路徑。


查看完整回答
反對 回復(fù) 2019-06-05
?
慕村9548890

TA貢獻1884條經(jīng)驗 獲得超4個贊

可以使用以下代碼獲取當前應(yīng)用程序目錄。

AppDomain.CurrentDomain.BaseDirectory


查看完整回答
反對 回復(fù) 2019-06-05
?
拉風的咖菲貓

TA貢獻1995條經(jīng)驗 獲得超2個贊

您有兩個查找應(yīng)用程序目錄的選項,您選擇的目錄將取決于您的目的。


// to get the location the assembly is executing from

//(not necessarily where the it normally resides on disk)

// in the case of the using shadow copies, for instance in NUnit tests, 

// this will be in a temp directory.

string path = System.Reflection.Assembly.GetExecutingAssembly().Location;


//To get the location the assembly normally resides on disk or the install directory

string path = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;


//once you have the path you get the directory with:

var directory = System.IO.Path.GetDirectoryName(path);


查看完整回答
反對 回復(fù) 2019-06-05
  • 3 回答
  • 0 關(guān)注
  • 972 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號