Westwind.Globalization.DbResXConverter.ImportDirectoryResources C# (CSharp) Method

ImportDirectoryResources() public method

Imports all resources from a given directory. This method works for any resources. When using LocalResources, make sure to provide an app relative path as the second parameter if the resources live in non root folder. So if you have resources in off an Admin folder use "admin/" as the parameter. Otherwise for web root resources or global or assembly level assemblies pass string.Empty or null.
public ImportDirectoryResources ( string path, string relativePath ) : bool
path string Physical Path for the Resources
relativePath string Optional - relative path prefix for Web App_LocalResources (ie. admin/)
return bool
        public bool ImportDirectoryResources(string path, string relativePath)
        {
            if (string.IsNullOrEmpty(relativePath))
                relativePath = "";

            string[] Files = Directory.GetFiles(path, "*.resx");
         
            foreach (string CurFile in Files)
            {
                string file = CurFile;//.ToLower();
                
                //string[] tokens = file.Replace(".resx","").Split('.');                
                string[] tokens = Path.GetFileName(file).Replace(".resx", "").Split('.');
                

                // ResName: admin/default.aspx or default.aspx or resources (global or assembly resources)
                string localeId = "";
                string resName = relativePath + Path.GetFileNameWithoutExtension(tokens[0]);


                if (resName.Contains("App_LocalResources/"))
                    resName = resName.Replace("App_LocalResources/", "");
                else if (resName.Contains("App_GlobalResources/"))
                    resName = resName.Replace("App_GlobalResources/", "");


                if (tokens.Length > 1)
                {
                    string extension = tokens[1];
                    if ("aspx|ascx|master|sitemap|".Contains(extension.ToLower() + "|") )
                        resName += "." + extension;
                    else
                        localeId = extension;
                }
                if (tokens.Length > 2)
                {
                    localeId = tokens[2];
                }

                ImportResourceFile(file, resName, localeId);
            }

            return true;
        }