Csharp/CSharp Tutorial/GUI Windows Forms/Resource File — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
| |
Текущая версия на 12:15, 26 мая 2010
Read resource from a .resource file
using System;
using System.Resources;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;
class MainClass
{
static void Main(string[] args)
{
ResourceWriter rw;
rw = new ResourceWriter("myResources.resources");
rw.AddResource("YourImage", new Bitmap("YourFile.Bmp"));
rw.AddResource("welcomeString", "Welcome to .NET resources.");
rw.Generate();
ResourceManager rm = new ResourceManager("myResources", Assembly.GetExecutingAssembly());
// Load image resource.
Bitmap b = (Bitmap)rm.GetObject("YourImage");
Console.WriteLine( rm.GetString("welcomeString"));
}
}Resource Generator: Make a new *resources file
using System;
using System.Resources;
using System.Drawing;
using System.Windows.Forms;
using System.Reflection;
class MainClass
{
static void Main(string[] args)
{
ResourceWriter rw;
rw = new ResourceWriter("myResources.resources");
rw.AddResource("YourImage", new Bitmap("YourFile.Bmp"));
rw.AddResource("welcomeString", "Welcome to .NET resources.");
rw.Generate();
}
}