ResourceWriter rw =new ResourceWriter("Greeting1.dll"); Bitmap b =new Bitmap("hhw.gif"); //add some strings to the file //rw.AddResource("Greeting", "Welcome to Microsoft .Net Framework!Test"); //rw.AddResource("PasswordException", "Sorry, that is not the correct password."); //rw.AddResource("Purchase", "Please select an item to purchase from the store:"); //rw.AddResource("Goodbye", "Thank you for visiting Microsoft .Net Framework!"); rw.AddResource("flag",b ); rw.Generate(); rw.Close();
以上注释的代码都可以打开使用
读资源文件的代码
ResourceReader rr =new ResourceReader("Greeting1.dll"); String s =""; //iterate through the reader, printing out the name-value pairs foreach (DictionaryEntry d in rr) { Console.WriteLine(d.Key +":"+ d.Value.ToString ()) ; if (d.Key.ToString () =="flag") { Bitmap b =new Bitmap((Bitmap)d.Value); b.Save("a.gif"); break; } } //close the reader rr.Close();