2013-06-24 68 views
0

在我的C#窗口項目中,我創建了一個安裝程序文件。我在程序文件夾中添加了一些圖像。所以我想找到程序文件夾並獲取圖像。如何獲取程序文件位置?

任何人都知道如何找到它?

回答

1

我做到這一點像,只是做一個文件夾,把它的資源,並在其中添加圖像文件和檢索像這樣,最後加資源文件夾中,同時使建立。我發現這很簡單。

Image imageNormal = Image.FromFile("Resources\\button_Image.png"); 
controlName.Image = imageNormal; 

在情況下,如果你正在尋找這個

C# - How to get Program Files (x86) on Windows 64 bit

How do get the path of Program Files regardless of the architecture of the target machine

2

可以使用Application.ExecutablePath財產

獲取啓動了應用程序,包括 可執行文件名的可執行文件的路徑。

+0

謝謝你回答我的問題。 'Application.ExecutablePath'顯示可執行文件的位置。我想要windows程序文件的位置。 –

+0

@ r.vengadesh看看我更新的答案,可能會有所幫助。 – Mogli

1

這很容易,試試下面的代碼AppDomain.CurrentDomain .BaseDirectory

你可以試試這個代碼來獲取iamges

Image.FormFile("Imagename.jpeg") 

這個代碼本身例如位於應用程序direcotry如果你寫 Image.FromFile("Imagename.jpeg")那麼它將retrive在bin文件夾中的圖像,

相關問題