获取程序资源 Pagebase.cs 中。获取数据:Resources["ADDNEW_SUCCESS"]
/// <summary>
/// 获取程序资源
/// </summary>
protected static ResourcesCollection Resources = new ResourcesCollection( Assembly.GetExecutingAssembly(),"Info");
获取程序资源对应的资源文件:Resources/Info.resx
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
namespace ZF_ERP.Common
{
/// <summary>
///日期:-12-19 签名:lj
///获取程序资源对应的资源文件:Resources/Info.resx
/// </summary>
public class ResourcesCollection
{
private ResourceManager m_resourceManager;
/// <summary>
/// 获取程序资源
/// </summary>
/// <param name="assembly">当前运行的程序集</param>
/// <param name="assemblyType">获取的资源类型。SqlCmd:SQL语句;Info:提示信息</param>
public ResourcesCollection( Assembly assembly,string assemblyType)
{
string assemblyName="";
switch (assemblyType.ToUpper())
{
//m_resourceManager = new ResourceManager( assembly.GetName().Name, assembly );
case "SQLCMD":
assemblyName=assembly.GetName().Name+".Resources.SqlCmd";
break;
case "INFO":
assemblyName=assembly.GetName().Name+".Resources.Info";
break;
}
m_resourceManager = new ResourceManager(assemblyName, assembly );
}
/// <summary>
/// Default property for accessing resources
/// <param name="index">
/// Index for the desired resource</param>
/// <returns>
/// Resource string value</returns>
///</summary>
public string this[ Enum index ]
{
get
{
return m_resourceManager.GetString( index.GetType().Name + "." + Enum.Format( index.GetType(), index, "G" ) );
}
}
/// <summary>
/// Default property for accessing resources
/// <param name="name">
/// Name of the desired resource</param>
/// <returns>
/// Resource string value</returns>
/// </summary>
public string this[ string name ]
{
get
{
return m_resourceManager.GetString( name );
}
}
}
}