曙光熹微吧 关注:12贴子:625
  • 9回复贴,共1
[C#]
using System;
using System.Drawing;
using System.Resources;
 
public class SampleClass
{
    public static void Main() 
    {
        Image img = Image.FromFile("en-AU.jpg");
        ResXResourceWriter rsxw = new ResXResourceWriter("en-AU.resx"); 
        rsxw.AddResource("en-AU.jpg",img);
        rsxw.Close();
    }
}


1楼2006-06-01 09:30回复
    [Visual Basic]
    Imports System
    Imports System.Drawing
    Imports System.Resources

    Public Class SampleClass

     Public Sub Main()
     Dim img As Image
     Dim rsxw As ResXResourceWriter
     img = Image.FromFile("en-AU.jpg")
     rsxw = new ResXResourceWriter("en-AU.resx")
     rsxw.AddResource("en-AU.jpg",img)
     rsxw.Close()
     End Sub
    End Class


    2楼2006-06-01 09:30
    回复
      [C#] 
      using System;
      using System.Resources;
      using System.Collections;

      class ReadResXResources
      {
       public static void Main()
       {
       
       // Create a ResXResourceReader for the file items.resx.
       ResXResourceReader rsxr = new ResXResourceReader("items.resx");

       // Create an IDictionaryEnumerator to iterate through the resources.
       IDictionaryEnumerator id = rsxr.GetEnumerator(); 

       // Iterate through the resources and display the contents to the console.
       foreach (DictionaryEntry d in rsxr) 
       {
       Console.WriteLine(d.Key.ToString() + ":\t" + d.Value.ToString());
       }

       //Close the reader.
       rsxr.Close();
       }
      }


      3楼2006-06-01 09:31
      回复
        C#] 
        using System;
        using System.Resources;
        using System.Collections;
         
        public class ReadResources {

         public static void Main(string[] args) {

         // Opens a resource reader and gets an enumerator from it.
         IResourceReader reader = new ResourceReader("myResources.resources");
         IDictionaryEnumerator en = reader.GetEnumerator();
         
         // Goes through the enumerator, printing out the key and value pairs.
         while (en.MoveNext()) {
         Console.WriteLine();
         Console.WriteLine("Name: {0}", en.Key);
         Console.WriteLine("Value: {0}", en.Value);
         }
         reader.Close();
         }
        }


        4楼2006-06-01 09:33
        回复
          [C#] 
          using System;
          using System.Resources;
          using System.Collections;

          class EnumerateResources 
          {
           public static void Main() 
           {
           // Create a ResourceSet for the file items.resources.
           ResourceSet rs = new ResourceSet("items.resources"); 

           
           // Create an IDictionaryEnumerator to read the data in the ResourceSet.
           IDictionaryEnumerator id = rs.GetEnumerator(); 

           // Iterate through the ResourceSet and display the contents to the console. 
           while(id.MoveNext())
           Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value); 

           rs.Close();
           
           }
          }


          5楼2006-06-01 09:39
          回复
            [C#] 
            using System;
            using System.Resources;


            public class WriteResources {
             public static void Main(string[] args) {
             
             // Creates a resource writer.
             IResourceWriter writer = new ResourceWriter("myResources.resources");
             
             // Adds resources to the resource writer.
             writer.AddResource("String 1", "First String");

             writer.AddResource("String 2", "Second String");

             writer.AddResource("String 3", "Third String");

             // Writes the resources to the file or stream, and closes it.
             writer.Close();
             }
            }


            6楼2006-06-01 09:40
            回复
              [C#] 
              using System;
              using System.Globalization;
              using System.Threading;
              using System.Resources;
              using System.Reflection;

              class ResourcesExample 
              {
               public static void Main() 
               {
               // Create a resource manager to retrieve resources.
               ResourceManager rm = new ResourceManager("items", 
               Assembly.GetExecutingAssembly());

               // Get the culture of the currently executing thread.
               // The value of ci will determine the culture of
               // the resources that the resource manager retrieves.
               CultureInfo ci = Thread.CurrentThread.CurrentCulture;
               
               // Retrieve the value of the string resource named 
               // "welcome", localized for the culture specified by ci.
               String str = rm.GetString("welcome", ci);
               Console.WriteLine(str);
               }
              }


              7楼2006-06-01 09:40
              回复
                s


                8楼2006-06-01 09:42
                回复
                  public static string GetResourceByKey(string resourceName,string key)
                   {
                   // Create a resource manager to retrieve resources.
                   ResourceManager rm = new ResourceManager(resourceName, Assembly.GetExecutingAssembly());
                   
                   rm.IgnoreCase = true;
                   // Retrieve the value of the string resource named 
                   string strValue = rm.GetString(key);
                   
                   rm = null;
                   return strValue;
                   }


                  9楼2006-06-01 10:08
                  回复
                    ...........

                    copy.........


                    10楼2007-05-04 19:27
                    回复