日期:2014-05-18 浏览次数:22037 次
public class CreatResource { //System.Windows.Forms.Application.StartupPath+ private static string Skin_Path = Environment.CurrentDirectory + "\\Skin\\";//皮肤文件夹路径 /// <summary> /// 创建资源文件 /// </summary> public static bool Create() { if (!System.IO.File.Exists("Jayn.resources")) { ResourceWriter rw = new ResourceWriter("Jayn.resources");//创建一个资源文件 try { Image Top_Left = Image.FromFile(Skin_Path + "Top_Left.gif"); rw.AddResource("Top_Left.gif", Top_Left); rw.Generate(); rw.Close(); return true; } catch { rw.Close(); return false; throw new ArgumentException(Skin_Path); } } return true; } }
try { CResource = CreatResource.Create();创建一个资源文件 if(CResource) { rm = new ResourceManager("Jayn.API.Jayn", System.Reflection.Assembly.GetExecutingAssembly()); //读取图片 Top_Left = (Bitmap)rm.GetObject("Top_Left.gif"); } } catch (Exception e) { throw new ArgumentException(e.Message); }