我需要獲取路徑。我需要在項目中獲取文件夾路徑
"C:\Projects\ProjectName\ConfigFiles\filename.txt"
這是Windows應用程序。安裝此應用程序後,我需要從安裝的路徑訪問「filename.txt」。
我已經嘗試了許多代碼像
Assembly.GetExecutingAssembly().Location
System.IO.Directory.GetCurrentDirectory()
etc...
這些所有的代碼返回 「C:\項目\項目名\ BIN \調試」 路徑。 請幫忙。
在此先感謝。
似乎是從Visual Studio IDE運行應用程序。如果您將從安裝的目錄運行應用程序,則應該獲取已安裝的目錄路徑。 – jags
什麼是Application.StartupPath? – urlreader
http://stackoverflow.com/questions/6041332/best-way-to-get-application-folder-path –