2011-05-10 7 views

Respuesta

-1

En Cs archivo escriba el espacio de nombres de localización:

Localization.Resources.KeyName 

fácil y rápido :)

+0

Dónde consigue el objeto Localization? – Muflix

8
public string ReadResourceValue(string file, string key) 

{ 

    string resourceValue = string.Empty; 
    try 
    { 

     string resourceFile = file; 

     string filePath = System.AppDomain.CurrentDomain.BaseDirectory.ToString(); 

     ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null); 
     // retrieve the value of the specified key 
     resourceValue = resourceManager.GetString(key); 
    } 
    catch (Exception ex) 
    { 
     Console.WriteLine(ex.Message); 
     resourceValue = string.Empty; 
    } 
    return resourceValue; 
} 
3

Hay una manera mucho más fácil: Namespace.Properties.Resources.FileName -> tiene la cadena del contenido del archivo.

es decir .: TestProject1.Properties.Resources.MyXmlFile -> acceso directo al archivo en los recursos

-1

Puede obtener keyvalue de global resource aquí.

//TestResource is resource class name. 

String keyValue=string.Empty; 

keyValue= Resources.TestResource.KeyString; 
Cuestiones relacionadas