473,395 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

App_GlobalResources List All Strings

I would like to list/enumerate all the strings in my resources files
in an ASP.NET 2.0 web application, for my own personal convenience.

I just want to be able to display the information

key1 string1
key2 string2

Nothing fancy.

I've looked at ResourceReader/ResourceManager but I'm not making any
headway.

Jul 5 '07 #1
4 7239
Howdy,

ResourceSet resources = Resources.Resource.ResourceManager.GetResourceSet(
new System.Globalization.CultureInfo("en"), false, true);

IDictionaryEnumerator enumerator = resources.GetEnumerator();

while (enumerator.MoveNext())
{
string key = (string) enumerator.Key;
string value = (string) enumerator.Value;
}

Hope this helps
--
Milosz
"ni***********@gmail.com" wrote:
I would like to list/enumerate all the strings in my resources files
in an ASP.NET 2.0 web application, for my own personal convenience.

I just want to be able to display the information

key1 string1
key2 string2

Nothing fancy.

I've looked at ResourceReader/ResourceManager but I'm not making any
headway.

Jul 6 '07 #2
Hey Milosz,

I had been using similar code to what you have just suggested.
Unfortunately I can't seem to get a reference to the Resource file,
so:

ResourceSet resources =
Resources.Resource.ResourceManager.GetResourceSet(

resources is null :/

My workaround, which is a little ugly is:

String pathName = Server.MapPath("App_GlobalResources");
ResXResourceSet resFile = new ResXResourceSet(pathName + "\
\Time.resx");
IDictionaryEnumerator idenum = resFile.GetEnumerator();
Incidentally I tried replacing:
ResourceSet resources =
Resources.Resource.ResourceManager.GetResourceSet(
with:
ResourceSet resources =
Resources.Time.ResourceManager.GetResourceSet(
Jul 6 '07 #3
You could also use:
Type type = typeof(System.Web.Compilation.BuildManager);

PropertyInfo propertyInfo = type.GetProperty("AppResourcesAssembly",
BindingFlags.Static |
BindingFlags.GetField |
BindingFlags.NonPublic);

Assembly assembly = (Assembly) propertyInfo.GetValue(null, null);

string[] names = assembly.GetManifestResourceNames();
string resource = names[0];
string baseName = resource.Substring(0, resource.LastIndexOf('.'));

ResourceManager manager = new ResourceManager(baseName, assembly);

ResourceSet resources = manager.GetResourceSet(
System.Globalization.CultureInfo.CurrentCulture, true, true);

IDictionaryEnumerator enumerator = resources.GetEnumerator();

while (enumerator.MoveNext())
{
string key = (string) enumerator.Key;
string value = (string)enumerator.Value;
}

Regards
--
Milosz
"ni***********@gmail.com" wrote:
Hey Milosz,

I had been using similar code to what you have just suggested.
Unfortunately I can't seem to get a reference to the Resource file,
so:

ResourceSet resources =
Resources.Resource.ResourceManager.GetResourceSet(

resources is null :/

My workaround, which is a little ugly is:

String pathName = Server.MapPath("App_GlobalResources");
ResXResourceSet resFile = new ResXResourceSet(pathName + "\
\Time.resx");
IDictionaryEnumerator idenum = resFile.GetEnumerator();
Incidentally I tried replacing:
ResourceSet resources =
Resources.Resource.ResourceManager.GetResourceSet(
with:
ResourceSet resources =
Resources.Time.ResourceManager.GetResourceSet(
Jul 6 '07 #4
You've been very helpful Milosz, thanks for your time. I'll use your
advice and get back to my task :)

Jul 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Adam | last post by:
Trying to get an asp.net 2.0 app running and am receiving this error. I see a bunch of people with this error on the net, but no solution: Works fine on my local machine, deployed to a server it...
0
by: Jody Gelowitz | last post by:
VS2005 Standard Edition WinXP Pro SP2 I have setup a Web project under: http://localhost/myproject/ and have received a "Failed to map the path '/MyProject/App_GlobalResources'." error...
6
by: CuriousGeorge | last post by:
I've upgraded a .Net 1.1 web app to 2.0 and am having a heck of a time getting resources to work again. From what I understand if I move my strings.resx file into the App_GlobalResources folder I...
0
by: ad | last post by:
I am using VS2005 to develop Web Application. After development, I install the Web application into another computer. But it faill to run with message: Can use /MyApp/App_GlobalResources/, because...
0
by: ad | last post by:
I am using vs2005 to develop an Web Service application. I have inserted a Text File into the the App_GlobalResources directory. How can I get the text file in program?
1
by: kurt sune | last post by:
This drives me nuts,I have put a textfile in App_GlobalResources. How do I read it in runtime? I have googled for two days now. GetExecutingAssembly.GetManifestResourceStream("XYZ.xml") returns...
0
by: C. Moya | last post by:
When sites are published, App_GlobalResources seems to be compiled and is not updateable (even though you set "Allow this precompiled site to be updateable"). Is there any way to update global...
0
by: Benson Wong | last post by:
Under an ASP.NET application, I create folder \app_globalresource and some resource files. Question: 1. How can I generate all my forms resources strings to these resources files? 2. If I add...
1
by: Chara | last post by:
When I try to access a web application, I am getting. Failed to map the path '/App_GlobalResources' I have been having this issue on a regular basis on a Windows 2000 Server. To resolve this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.