How to check whethere a resource file is available or not? RRS feed

  • Question

  • User1042252450 posted

    Hi all,

       i need to bind a resource file using system culture info. Say for example, if my system culture is Spanish(Spain) "es-ES" then i have to look for "es-ES" resource file to bind. If it is not there then i have to bind with default resource file ('en-US"). How to do this?


    Friday, December 3, 2010 12:35 AM


All replies

  • User384031199 posted


    You need not add any specific code for this. .NET will take care of getting the culture specific resource file. If the culture specific resource file is not found, it will take up the the culture neutral resource file.

    Refer to this link.


    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 3, 2010 1:18 AM
  • User-886123767 posted

    check it out following article..

    U just need to set culture only. Based on culture it will fetch out value.



    Friday, December 3, 2010 1:29 AM
  • User712082397 posted

    From another post here

    Just make sure that you set this kind of code in your global.asax. This helps the resource manager to automatically pick the appropriate resource file

    Sub Application_BeginRequest(ByVal Sender As Object, ByVal e As EventArgs)  
             'Set the current culture based on what the browser sends to the server   
             Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages(0))  
         Catch e As Exception  
             'Give a default, if its not found  
             Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")  
         End Try  
         'set the current UI culture   
         'this will be used by the resource manager to retrieve values from resource files automatically   
         Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture  
     End Sub  

    And then you can use either GetGlobalResourceObject or GetLocalResourceObject(), depending on where your resource files are.

    Wednesday, December 8, 2010 11:15 AM