Beispiel #1
0
        public bool SavePara(string _path, IniDataFmt _obj)
        {
            bool res = true;

            try
            {
                //string sPath = System.Reflection.Assembly.GetAssembly(this.GetType()).Location;
                //create new
                if (!File.Exists(folderPath + "\\" + filename))
                {
                    File.Create(folderPath + "\\" + filename);
                }

                //save para.
                using (ExecuteIniClass IniFile = new ExecuteIniClass(Path.Combine(folderPath, filename)))
                {
                    IniFile.setKeyValue("Dev", "IP", _obj.IP);
                    IniFile.setKeyValue("Dev", "Path", _obj.Path);
                    IniFile.setKeyValue("Dev", "Browser", _obj.Browser);
                }
            }
            catch (Exception ex)
            {
                res = false;
            }

            return(res);
        }
Beispiel #2
0
        public IniDataFmt GetPara(string _path)
        {
            IniDataFmt data = new IniDataFmt()
            {
                IP = "", Path = "", Browser = ""
            };

            folderPath = "";
            string sPath          = System.Reflection.Assembly.GetAssembly(this.GetType()).Location;
            char   delimiterChars = '\\';

            string[] words = sPath.Split(delimiterChars);

            for (int i = 0; i < words.Length - 1; i++)
            {
                folderPath = folderPath + words[i] + "\\";
            }

            if (File.Exists(folderPath + "\\" + filename))
            {
                using (ExecuteIniClass IniFile = new ExecuteIniClass(Path.Combine(folderPath, filename)))
                {
                    data.IP      = IniFile.getKeyValue("Dev", "IP");
                    data.Path    = IniFile.getKeyValue("Dev", "Path");
                    data.Browser = IniFile.getKeyValue("Dev", "Browser");
                }
            }

            return(data);
            //create new
            //if (File.Exists(Application.StartupPath + "\\" + filename))
            //{
            //    using (ExecuteIniClass IniFile = new ExecuteIniClass(Path.Combine(Application.StartupPath, filename)))
            //    {
            //        GCtxtBox.Text = path = IniFile.getKeyValue("Dev", "Path");
            //    }
            //}
        }