Reputation: 5859
Question what do you do for request in Application_Start global asax i want to replace my path to my App_GlobalResources directory but i tried using request and it didn't work am i missing an assembly reference is there another way of doing it.
Updated Code:
List<string> languages = new List<string>
foreach (var file in Directory.EnumerateFiles(HttpContext.Current.Request.MapPath("App_GlobalResources"), "*.resx"))
{
string resource = Path.GetFileNameWithoutExtension(file);
if (resource.Length > 9)
{
string filename = resource.Substring(resource.IndexOf(".") + 1, resource.Length - resource.IndexOf(".") - 1);
RegionInfo regionInfo = new RegionInfo(filename);
if (!string.IsNullOrEmpty(filename))
{
llanguages.Add(filename);
} // error here
}
}
HttpContext.Current.Application.Add("Cultures", languages.ToArray());
Upvotes: 0
Views: 649
Reputation: 17485
List<string> languages = new List<string>();
foreach (var file in Directory.EnumerateFiles("C:\\Users\\KIRK\\Documents\\Visual Studio 2010\\WebSites\\WebSite2\\App_GlobalResources", "*.resx"))
{
string resource = Path.GetFileNameWithoutExtension(file);
if (resource.Length > 9) {
string filename = resource.Substring(resource.IndexOf(".") + 1, resource.Length - resource.IndexOf(".") - 1);
RegionInfo regionInfo = new RegionInfo(filename);
if (!string.IsNullOrEmpty(filename))
{ languages.Add(filename);
}
}
}
HttpContext.Current.Application.Add("Cultures", languages.ToArray());
Upvotes: 1