资源文件配置和使用
1.建立工程,比如Document,配置webconfig

资源文件配置和使用<appSettings>        
资源文件配置和使用        
<add key="DefaultCulture" value="zh-cn" />
资源文件配置和使用        
<add key="CNCulture" value="zh-cn" />
资源文件配置和使用        
<add key="ENCulture" value="en-us" />
资源文件配置和使用    
</appSettings>

2.添加资源文件
右键添加新项目,选中Assembly Resource File,命名为strings.en-us.resx和strings.zh-cn.resx,然后配置如下
2.1  strings.en-us.resx

资源文件配置和使用<?xml version="1.0" encoding="utf-8" ?>
资源文件配置和使用
<root>
资源文件配置和使用    
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
资源文件配置和使用        
<xsd:element name="root" msdata:IsDataSet="true">
资源文件配置和使用            
<xsd:complexType>
资源文件配置和使用                
<xsd:choice maxOccurs="unbounded">
资源文件配置和使用                    
<xsd:element name="data">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                                
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="type" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="mimetype" type="xsd:string" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                    
<xsd:element name="resheader">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" use="required" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                
</xsd:choice>
资源文件配置和使用            
</xsd:complexType>
资源文件配置和使用        
</xsd:element>
资源文件配置和使用    
</xsd:schema>
资源文件配置和使用    
<resheader name="ResMimeType">
资源文件配置和使用        
<value>text/microsoft-resx</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Version">
资源文件配置和使用        
<value>1.0.0.0</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Reader">
资源文件配置和使用        
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Writer">
资源文件配置和使用        
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<data name="LoginName">
资源文件配置和使用        
<value>Username</value>
资源文件配置和使用    
</data>
资源文件配置和使用    
<data name="Password">
资源文件配置和使用        
<value>Password</value>
资源文件配置和使用    
</data>    
资源文件配置和使用
</root>

2.2  strings.zh-cn.resx

资源文件配置和使用<?xml version="1.0" encoding="utf-8" ?>
资源文件配置和使用
<root>
资源文件配置和使用    
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
资源文件配置和使用        
<xsd:element name="root" msdata:IsDataSet="true">
资源文件配置和使用            
<xsd:complexType>
资源文件配置和使用                
<xsd:choice maxOccurs="unbounded">
资源文件配置和使用                    
<xsd:element name="data">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                                
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="type" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="mimetype" type="xsd:string" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                    
<xsd:element name="resheader">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" use="required" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                
</xsd:choice>
资源文件配置和使用            
</xsd:complexType>
资源文件配置和使用        
</xsd:element>
资源文件配置和使用    
</xsd:schema>
资源文件配置和使用    
<resheader name="ResMimeType">
资源文件配置和使用        
<value>text/microsoft-resx</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Version">
资源文件配置和使用        
<value>1.0.0.0</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Reader">
资源文件配置和使用        
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Writer">
资源文件配置和使用        
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<data name="LoginName">
资源文件配置和使用        
<value>用户名</value>
资源文件配置和使用    
</data>
资源文件配置和使用    
<data name="Password">
资源文件配置和使用        
<value>密码</value>
资源文件配置和使用    
</data>    
资源文件配置和使用
</root>
3.在Global.asax写如下代码
资源文件配置和使用protected void Application_BeginRequest(Object sender, EventArgs e)
        }
4.添加测试页面
4.1 html
资源文件配置和使用<HTML>
资源文件配置和使用    
<HEAD>
资源文件配置和使用        
<title>Login</title>
资源文件配置和使用        
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
资源文件配置和使用        
<meta name="CODE_LANGUAGE" Content="C#">
资源文件配置和使用        
<meta name="vs_defaultClientScript" content="JavaScript">
资源文件配置和使用        
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
资源文件配置和使用    
</HEAD>
资源文件配置和使用    
<body>
资源文件配置和使用        
<form id="Form1" method="post" runat="server">
资源文件配置和使用            
<table align="center" cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%">
资源文件配置和使用                
<colgroup>
资源文件配置和使用                    
<col width="20%">
资源文件配置和使用                    
</col>
资源文件配置和使用                    
<col width="60%">
资源文件配置和使用                    
</col>
资源文件配置和使用                    
<col width="20%">
资源文件配置和使用                    
</col>
资源文件配置和使用                
</colgroup>
资源文件配置和使用                
<tr>
资源文件配置和使用                    
<td></td>
资源文件配置和使用                    
<td valign="middle">
资源文件配置和使用                        
<TABLE id="Table1" align="center" cellSpacing="0" cellPadding="0" width="100%" border="0">
资源文件配置和使用                            
<colgroup>
资源文件配置和使用                                
<col width="50%">
资源文件配置和使用                                
</col>
资源文件配置和使用                                
<col width="50%">
资源文件配置和使用                                
</col>
资源文件配置和使用                            
</colgroup>
资源文件配置和使用                            
<TR>
资源文件配置和使用                                
<TD align="right">语言选择</TD>
资源文件配置和使用                                
<TD>
资源文件配置和使用                                    
<asp:Button id="Button1" runat="server" Text="中文"></asp:Button>
资源文件配置和使用                                    
<asp:Button id="Button2" runat="server" Text="英文"></asp:Button></TD>
资源文件配置和使用                            
</TR>
资源文件配置和使用                            
<TR>
资源文件配置和使用                                
<TD align="right">
资源文件配置和使用                                    
<asp:Label id="Label1" runat="server">Label</asp:Label></TD>
资源文件配置和使用                                
<TD>
资源文件配置和使用                                    
<asp:TextBox id="txtLoginName" runat="server" Width="100%"></asp:TextBox></TD>
资源文件配置和使用                            
</TR>
资源文件配置和使用                            
<TR>
资源文件配置和使用                                
<TD align="right">
资源文件配置和使用                                    
<asp:Label id="Label2" runat="server">Label</asp:Label></TD>
资源文件配置和使用                                
<TD>
资源文件配置和使用                                    
<asp:TextBox id="txtPassword" runat="server" Width="100%"></asp:TextBox></TD>
资源文件配置和使用                            
</TR>
资源文件配置和使用                        
</TABLE>
资源文件配置和使用                    
</td>
资源文件配置和使用                    
<TD></TD>
资源文件配置和使用                
</tr>
资源文件配置和使用            
</table>
资源文件配置和使用        
</form>
资源文件配置和使用    
</body>
资源文件配置和使用
</HTML>
4.2 cs代码
资源文件配置和使用using System;
资源文件配置和使用
using System.Collections;
资源文件配置和使用
using System.ComponentModel;
资源文件配置和使用
using System.Data;
资源文件配置和使用
using System.Drawing;
资源文件配置和使用
using System.Web;
资源文件配置和使用
using System.Web.SessionState;
资源文件配置和使用
using System.Web.UI;
资源文件配置和使用
using System.Web.UI.WebControls;
资源文件配置和使用
using System.Web.UI.HtmlControls;
资源文件配置和使用
using System.Configuration;
资源文件配置和使用
using System.Threading;
资源文件配置和使用
using System.Resources;
资源文件配置和使用
using System.Globalization;
资源文件配置和使用
using System.Diagnostics;
资源文件配置和使用
using System.Reflection;
资源文件配置和使用
namespace Document
}
5.源代码下载/Files/singlepine/Resource.rar
6.资源文件配置小工具使用XML读写删除功能来实现资源文件配置

资源文件配置和使用
1.建立工程,比如Document,配置webconfig

资源文件配置和使用<appSettings>        
资源文件配置和使用        
<add key="DefaultCulture" value="zh-cn" />
资源文件配置和使用        
<add key="CNCulture" value="zh-cn" />
资源文件配置和使用        
<add key="ENCulture" value="en-us" />
资源文件配置和使用    
</appSettings>

2.添加资源文件
右键添加新项目,选中Assembly Resource File,命名为strings.en-us.resx和strings.zh-cn.resx,然后配置如下
2.1  strings.en-us.resx

资源文件配置和使用<?xml version="1.0" encoding="utf-8" ?>
资源文件配置和使用
<root>
资源文件配置和使用    
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
资源文件配置和使用        
<xsd:element name="root" msdata:IsDataSet="true">
资源文件配置和使用            
<xsd:complexType>
资源文件配置和使用                
<xsd:choice maxOccurs="unbounded">
资源文件配置和使用                    
<xsd:element name="data">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                                
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="type" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="mimetype" type="xsd:string" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                    
<xsd:element name="resheader">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" use="required" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                
</xsd:choice>
资源文件配置和使用            
</xsd:complexType>
资源文件配置和使用        
</xsd:element>
资源文件配置和使用    
</xsd:schema>
资源文件配置和使用    
<resheader name="ResMimeType">
资源文件配置和使用        
<value>text/microsoft-resx</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Version">
资源文件配置和使用        
<value>1.0.0.0</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Reader">
资源文件配置和使用        
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Writer">
资源文件配置和使用        
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<data name="LoginName">
资源文件配置和使用        
<value>Username</value>
资源文件配置和使用    
</data>
资源文件配置和使用    
<data name="Password">
资源文件配置和使用        
<value>Password</value>
资源文件配置和使用    
</data>    
资源文件配置和使用
</root>

2.2  strings.zh-cn.resx

资源文件配置和使用<?xml version="1.0" encoding="utf-8" ?>
资源文件配置和使用
<root>
资源文件配置和使用    
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
资源文件配置和使用        
<xsd:element name="root" msdata:IsDataSet="true">
资源文件配置和使用            
<xsd:complexType>
资源文件配置和使用                
<xsd:choice maxOccurs="unbounded">
资源文件配置和使用                    
<xsd:element name="data">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                                
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="type" type="xsd:string" />
资源文件配置和使用                            
<xsd:attribute name="mimetype" type="xsd:string" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                    
<xsd:element name="resheader">
资源文件配置和使用                        
<xsd:complexType>
资源文件配置和使用                            
<xsd:sequence>
资源文件配置和使用                                
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
资源文件配置和使用                            
</xsd:sequence>
资源文件配置和使用                            
<xsd:attribute name="name" type="xsd:string" use="required" />
资源文件配置和使用                        
</xsd:complexType>
资源文件配置和使用                    
</xsd:element>
资源文件配置和使用                
</xsd:choice>
资源文件配置和使用            
</xsd:complexType>
资源文件配置和使用        
</xsd:element>
资源文件配置和使用    
</xsd:schema>
资源文件配置和使用    
<resheader name="ResMimeType">
资源文件配置和使用        
<value>text/microsoft-resx</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Version">
资源文件配置和使用        
<value>1.0.0.0</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Reader">
资源文件配置和使用        
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<resheader name="Writer">
资源文件配置和使用        
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
资源文件配置和使用    
</resheader>
资源文件配置和使用    
<data name="LoginName">
资源文件配置和使用        
<value>用户名</value>
资源文件配置和使用    
</data>
资源文件配置和使用    
<data name="Password">
资源文件配置和使用        
<value>密码</value>
资源文件配置和使用    
</data>    
资源文件配置和使用
</root>
3.在Global.asax写如下代码
资源文件配置和使用protected void Application_BeginRequest(Object sender, EventArgs e)
        }
4.添加测试页面
4.1 html
资源文件配置和使用<HTML>
资源文件配置和使用    
<HEAD>
资源文件配置和使用        
<title>Login</title>
资源文件配置和使用        
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
资源文件配置和使用        
<meta name="CODE_LANGUAGE" Content="C#">
资源文件配置和使用        
<meta name="vs_defaultClientScript" content="JavaScript">
资源文件配置和使用        
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
资源文件配置和使用    
</HEAD>
资源文件配置和使用    
<body>
资源文件配置和使用        
<form id="Form1" method="post" runat="server">
资源文件配置和使用            
<table align="center" cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%">
资源文件配置和使用                
<colgroup>
资源文件配置和使用                    
<col width="20%">
资源文件配置和使用                    
</col>
资源文件配置和使用                    
<col width="60%">
资源文件配置和使用                    
</col>
资源文件配置和使用                    
<col width="20%">
资源文件配置和使用                    
</col>
资源文件配置和使用                
</colgroup>
资源文件配置和使用                
<tr>
资源文件配置和使用                    
<td></td>
资源文件配置和使用                    
<td valign="middle">
资源文件配置和使用                        
<TABLE id="Table1" align="center" cellSpacing="0" cellPadding="0" width="100%" border="0">
资源文件配置和使用                            
<colgroup>
资源文件配置和使用                                
<col width="50%">
资源文件配置和使用                                
</col>
资源文件配置和使用                                
<col width="50%">
资源文件配置和使用                                
</col>
资源文件配置和使用                            
</colgroup>
资源文件配置和使用                            
<TR>
资源文件配置和使用                                
<TD align="right">语言选择</TD>
资源文件配置和使用                                
<TD>
资源文件配置和使用                                    
<asp:Button id="Button1" runat="server" Text="中文"></asp:Button>
资源文件配置和使用                                    
<asp:Button id="Button2" runat="server" Text="英文"></asp:Button></TD>
资源文件配置和使用                            
</TR>
资源文件配置和使用                            
<TR>
资源文件配置和使用                                
<TD align="right">
资源文件配置和使用                                    
<asp:Label id="Label1" runat="server">Label</asp:Label></TD>
资源文件配置和使用                                
<TD>
资源文件配置和使用                                    
<asp:TextBox id="txtLoginName" runat="server" Width="100%"></asp:TextBox></TD>
资源文件配置和使用                            
</TR>
资源文件配置和使用                            
<TR>
资源文件配置和使用                                
<TD align="right">
资源文件配置和使用                                    
<asp:Label id="Label2" runat="server">Label</asp:Label></TD>
资源文件配置和使用                                
<TD>
资源文件配置和使用                                    
<asp:TextBox id="txtPassword" runat="server" Width="100%"></asp:TextBox></TD>
资源文件配置和使用                            
</TR>
资源文件配置和使用                        
</TABLE>
资源文件配置和使用                    
</td>
资源文件配置和使用                    
<TD></TD>
资源文件配置和使用                
</tr>
资源文件配置和使用            
</table>
资源文件配置和使用        
</form>
资源文件配置和使用    
</body>
资源文件配置和使用
</HTML>
4.2 cs代码
资源文件配置和使用using System;
资源文件配置和使用
using System.Collections;
资源文件配置和使用
using System.ComponentModel;
资源文件配置和使用
using System.Data;
资源文件配置和使用
using System.Drawing;
资源文件配置和使用
using System.Web;
资源文件配置和使用
using System.Web.SessionState;
资源文件配置和使用
using System.Web.UI;
资源文件配置和使用
using System.Web.UI.WebControls;
资源文件配置和使用
using System.Web.UI.HtmlControls;
资源文件配置和使用
using System.Configuration;
资源文件配置和使用
using System.Threading;
资源文件配置和使用
using System.Resources;
资源文件配置和使用
using System.Globalization;
资源文件配置和使用
using System.Diagnostics;
资源文件配置和使用
using System.Reflection;
资源文件配置和使用
namespace Document
}
5.源代码下载/Files/singlepine/Resource.rar
6.资源文件配置小工具使用XML读写删除功能来实现资源文件配置

相关文章: