AniDBmini.ConfigFile.CheckDefaultConfig C# (CSharp) Method

CheckDefaultConfig() private static method

Check if the config file exists, or if it is emtpy. If either, create a config file w/defaults.
private static CheckDefaultConfig ( ) : void
return void
        private static void CheckDefaultConfig()
        {
            if (!File.Exists(configPath) || string.IsNullOrWhiteSpace(File.ReadAllText(configPath)))
            {
                try
                {
                    using (StreamWriter sw = File.CreateText(configPath))
                        sw.WriteLine("[" + configSection + "]");
                }
                catch (DirectoryNotFoundException)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(configPath));
                }
                finally
                {
                    using (StreamWriter sw = File.CreateText(configPath))
                        sw.WriteLine("[" + configSection + "]");
                }

                foreach (KeyValuePair<string, string> kvp in Default)
                    Write(kvp.Key, kvp.Value);
            }
        }