TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Read Resource File RESX File
Vishal Misquitta
Aug 26
2016
Code
946
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
using
System;
namespace
ASPNET {
public
partial
class
ReadResourceValue: System.Web.UI.Page {
protected
void
Page_Load(
object
sender, EventArgs e) {
//In the Resource file properties. Set Build Action = Embedded Resource
string
strResourceValue = GetResource(
"ResourceName"
);
}
public
string
GetResource(
string
strResourceKey) {
string
strResult =
string
.Empty;
try
{
if
(!
string
.IsNullOrEmpty(strResourceKey)) {
//APPNET.MyResourceFile ASPNET = my project name & MyResourceFile = Resource file name
System.Resources.ResourceManager objResourceManager =
new
System.Resources.ResourceManager(
"ASPNET.MyResourceFile"
,
typeof
(ReadResourceValue).Assembly);
string
value = objResourceManager.GetString(strResourceKey).ToString();
}
}
catch
(Exception ex) {
Console.Write(ex.ToString());
}
return
strResult;
}
}
}
C#
Read Resource File
RESX File