--
利用到Assembly的GetManifestResourceStream來載入資源(建置動作:內嵌資源)
using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Reflection;//要記得using namespace WindowsApplication1 { public partial class GetResourceStream : Form { public GetResourceStream() { InitializeComponent(); } private void GetResourceStream_Load(object sender, EventArgs e) { Assembly asm = Assembly.GetExecutingAssembly(); string name = asm.GetName().Name; Bitmap bmp = new Bitmap(asm.GetManifestResourceStream(name + ".f6.jpg"));//載入圖片資源 this.pictureBox1.Image = bmp; } } }
沒有留言:
張貼留言