0
votes

i have created a resource file "Resource.resx" in my project and added some values against some keys(string values) now when i try to access the value i get the following error...

Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: Resource locationInfo: fileName: Resource.resources

im accessing the resource.resx by following code

string key = "Home";
             string resourceValue = string.Empty;
             string resourceFile = "Resource";//name of my resource file Resource.resx

             string filePath =System.AppDomain.CurrentDomain.BaseDirectory.ToString();

             ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null);


             resourceValue = resourceManager.GetString(key);

im using mvc.net... plz help

1

1 Answers

2
votes

Why don't you use the class automatically generated by Visual Studio when you added the Resource.resx file (Resource.Designer.cs). This way you don't need to write all the code you wrote.

// assuming you've added a Home key in the resource file
string resourceValue = Resource.Home;