C# 如何读取嵌入式资源
推荐于2018-05-14 · 知道合伙人软件行家
关注
展开全部
Assembly assembly = GetType().Assembly;
System.IO.Stream streamSmall = assembly.GetManifestResourceStream("WindowsFormsApplication1.event.jpg");
//当作为一个资源被嵌入后,资源的完整名称会由项目的默认命名空间与文件名组成
Bitmap BackgroundImg = new Bitmap(streamSmall);
pictureBox1.Image = BackgroundImg;
Assembly assembly = GetType().Assembly;
System.IO.Stream streamSmall = assembly.GetManifestResourceStream("WindowsFormsApplication1.NewFolder1.TextFile1.txt");
StreamReader sr = new StreamReader(streamSmall);
string text = sr.ReadToEnd();
MessageBox.Show(text);
System.IO.Stream streamSmall = assembly.GetManifestResourceStream("WindowsFormsApplication1.event.jpg");
//当作为一个资源被嵌入后,资源的完整名称会由项目的默认命名空间与文件名组成
Bitmap BackgroundImg = new Bitmap(streamSmall);
pictureBox1.Image = BackgroundImg;
Assembly assembly = GetType().Assembly;
System.IO.Stream streamSmall = assembly.GetManifestResourceStream("WindowsFormsApplication1.NewFolder1.TextFile1.txt");
StreamReader sr = new StreamReader(streamSmall);
string text = sr.ReadToEnd();
MessageBox.Show(text);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询