| Author: DurgaprasadCh 24 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
Ramya,
I hope, validating for null value should work out.
if (resource.GetString("mystring") != null) {...} else {...}
Please revert back if this is not what you are looking for or if you find correct answer.
-Durga
|
| Author: Ramya 25 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
Hi Durgaprasad,
Thanks for your reply.
I tried it equating to null as the same as specified above. But it is giving me error once it comes to the line resource.GetString() not even checking for null.
|
| Author: DurgaprasadCh 25 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
hmmm...I believe "resource" would be declared and defined as ResourceManager right?
|
| Author: Ramya 25 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
yes, it is.
ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("resource", strResourcesPath, null);
and then rm.GetString("---");
I appreciate your continued help.
|
| Author: Ramya 25 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
Also, is there a way to find whether a string exists in resource file
|
| Author: Ramya 25 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
yes, it is.
ResourceManager rm = ResourceManager.CreateFileBasedResourceManager("resource", strResourcesPath, null);
and then rm.GetString("---");
I appreciate your continued help.
|
| Author: DurgaprasadCh 26 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
hmmm..I don't think we have any other specific method to verify whether string exists or not apart from using GetString.
Also, just a note, if the runtime fails to load or locate this culture specific resource, it will read the intended resource text from the default resource. So one work around is provide default strings in default .resources file to avoid runtime errors.
|
| Author: Ramya 27 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
Durgaprasad, Thanks for the info. It is interesting. Can u pls. give me a code sample for using default resource file.
|
| Author: DurgaprasadCh 31 Mar 2008 | Member Level: Silver | Rating: Points: 2 |
hey Ramya, Sorry!! I was out last week and just back in city today.
There is nothing much to do to create a default resource file, normally when you create culture specific resource file, you give name as resourcefile.es-ES.resources (for spanish) but create another file like resourcefile.resx this will act as default resource file for your application.
Lemme know if your problem got solved else we can look at alternatives.
-Durga.
|