Exemple #1
0
        internal static string GetWebConfigFileName(string dir)
        {
            AppDomain domain = AppDomain.CurrentDomain;
            bool      hosted = (domain.GetData(ApplicationHost.MonoHostedDataKey) as string) == "yes";

            if (hosted)
            {
                return(ApplicationHost.FindWebConfig(dir));
            }
            else
            {
                Assembly asm       = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly();
                string   name      = Path.GetFileName(asm.Location);
                string[] fileNames = new string[] { name + ".config", name + ".Config" };
                string   appDir    = domain.BaseDirectory;
                string   file;

                foreach (string fn in fileNames)
                {
                    file = Path.Combine(appDir, fn);
                    if (File.Exists(file))
                    {
                        return(file);
                    }
                }
            }
            return(null);
        }