SparkleLib.SparkleConfig.SparkleConfig C# (CSharp) Method

SparkleConfig() public method

public SparkleConfig ( string config_path, string config_file_name ) : System
config_path string
config_file_name string
return System
        public SparkleConfig(string config_path, string config_file_name)
        {
            FullPath    = Path.Combine (config_path, config_file_name);
            LogFilePath = Path.Combine (config_path, "debug_log.txt");

            if (File.Exists (LogFilePath)) {
                try {
                    File.Delete (LogFilePath);

                } catch (Exception) {
                    // Don't delete the debug.log if, for example, 'tail' is reading it
                }
            }

            if (!Directory.Exists (config_path))
                Directory.CreateDirectory (config_path);

            try {
              Load (FullPath);

            } catch (TypeInitializationException) {
                CreateInitialConfig ();

            } catch (FileNotFoundException) {
                CreateInitialConfig ();

            } catch (XmlException) {
                FileInfo file = new FileInfo (FullPath);

                if (file.Length == 0) {
                    File.Delete (FullPath);
                    CreateInitialConfig ();

                } else {
                    throw new XmlException (FullPath + " does not contain a valid config XML structure.");
                }

            } finally {
                Load (FullPath);
                TmpPath = Path.Combine (FoldersPath, ".tmp");
                Directory.CreateDirectory (TmpPath);
            }
        }