Esempio n. 1
0
        public static string GetConfig(string name)
        {
            string    value = "";
            MangGetOS getos = GetOSConfig();

            if (!Directory.Exists(getos.configpath))
            {
                Directory.CreateDirectory(getos.configpath);
            }
            if (!File.Exists(getos.config))
            {
                File.WriteAllText(getos.config, "=-Config-=");
            }
            string[] text = System.IO.File.ReadAllLines(getos.config);
            foreach (string cat in text)
            {
                if (cat.Length > name.Length)
                {
                    if (cat.Substring(0, name.Length + 1) == name + ":")
                    {
                        value = cat.Replace(name + ": ", "");
                    }
                }
            }
            return(value);
        }
Esempio n. 2
0
        public static void SetConfig(string item, string content)
        {
            MangGetOS getos = GetOSConfig();

            if (!Directory.Exists(getos.configpath))
            {
                Directory.CreateDirectory(getos.configpath);
            }
            string[]      text    = System.IO.File.ReadAllLines(getos.config);
            List <string> pz      = new List <string>();
            bool          writing = false;

            foreach (string cat in text)
            {
                if (cat.Length > item.Length)
                {
                    if (cat.Substring(0, item.Length + 1) == item + ":")
                    {
                        writing = true;
                        pz.Add(item + ": " + content);
                    }
                    else
                    {
                        pz.Add(cat);
                    }
                }
                else
                {
                    pz.Add(cat);
                }
            }
            if (!writing)
            {
                pz.Add(item + ": " + content);
            }
            File.WriteAllLines(getos.config, pz);
        }