2010-05-19 48 views
1

我在項目的Resources文件夾中添加了一個簡單的.gif文件。CF - 如何訪問我的資源文件夾中的.gif

現在我用pictureBox創建了一個用戶控件。 如何添加.gif到pictureBox.Image =新的位圖(路徑)。

這種情況下的路徑是什麼?

thanx!

回答

2

我想你可以通過以下方式做到這一點:

// Create a MemoryStream from the .gif file resource 
MemoryStream ms = new MemoryStream(YourApplicationName.Properties.Resources.GifFileName); 

// Instantiate a new Bitmap using the created MemoryStream 
pictureBox.Image = new Bitmap(ms); 

不能完全肯定這是否正常工作(不能在此刻進行測試),但它應該指向你在正確的方向。

+0

嗯我會試試看,thanx! – no9 2010-05-20 06:09:12

+0

讓我知道它是如何運作:) – pyrocumulus 2010-05-20 07:00:06

相關問題