首先將GIF資源嵌入到程序集中,然後在播放的時候再取出來,具體的如下: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
右鍵資源管理器--添加現有項目(添加一個名爲123的GIF圖片)
選中圖片,在屬性欄中把“生成操作”設爲“嵌入的資源”
代碼:
System.Reflection.Assembly thisExe;
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
//WindowsApplication1爲程序集的命名空間
//123.GIF爲圖片的名字
System.IO.Stream file = thisExe.GetManifestResourceStream( "WindowsApplication1.123.jpg ");
this.pictureBox1.Image = Image.FromStream(file);