GetManifestResourceStream的使用




C#中则是:项目命名空间.资源文件所在文件夹名.资源文件名

例:
[C# code]
Assembly assm = this.GetType().Assembly.GetExecutingAssembly();
istr = assm.GetManifestResourceStream("项目命名空间.资源文件所在文件夹名.资源文件名");
eg:

 public Bitmap LoadBitmap(string imageName, int width, int height)
        {
            return LoadBitmap(this.GetType().Assembly.GetManifestResourceStream("Sample.Images." + imageName + ScreenFactorSuffix + ".png"), width, height);
        }

        public Bitmap LoadBitmap(Stream s, int width, int height)
        {
            Bitmap dib = new Bitmap(s);
            Bitmap ddb = new Bitmap(width * ScreenFactor, height * ScreenFactor);
            Graphics g = Graphics.FromImage(ddb);
            g.DrawImage(dib, new Rectangle(0, 0, width * ScreenFactor, height * ScreenFactor), new Rectangle(0, 0, dib.Width, dib.Height), GraphicsUnit.Pixel);
            dib.Dispose();
            return ddb;
        }


你可能感兴趣的:(C#基础)