Beispiel #1
0
        /// <summary>
        ///     Create a new (empty) config file.
        /// </summary>
        private static void CreateEmptyConfig(string filepath)
        {
            Logger.Log(LogLevel.Info, "Config", "Creating config file");
            DirectoryInfo dirInfo = new FileInfo(filepath).Directory;

            if (dirInfo != null)
            {
                string parent = dirInfo.ToString();
                FsUtil.CreateDirectoryIfNotExists(parent);
            }

            FileStream   fs = File.Create(filepath);
            StreamWriter sw = new StreamWriter(fs);

            sw.WriteLine("<xml></xml>");
            sw.Close();
            fs.Close();
        }
Beispiel #2
0
        private static void LoadFile(string file)
        {
            _filepath = file;
            if (!File.Exists(file))
            {
                DirectoryInfo dirInfo = new FileInfo(file).Directory;
                if (dirInfo != null)
                {
                    string parent = dirInfo.ToString();
                    FsUtil.CreateDirectoryIfNotExists(parent);
                }

                FileStream   fs = File.Create(file);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(XmlHead + XmlTail);
                sw.Close();
                fs.Close();
            }

            _xmldoc = new XmlDocument();
            _xmldoc.Load(file);
        }