Beispiel #1
0
        /// <summary>
        /// 读取配置文件中的FTP服务信息列表
        /// </summary>
        /// <returns></returns>
        public static List <ServerInfo> GetServerList()
        {
            List <ServerInfo> list = new List <ServerInfo>();
            string            path = Application.StartupPath.ToString() + "\\server.json";
            string            json = string.Empty;
            StreamReader      sr   = File.OpenText(path);

            try
            {
                json = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(json))
                {
                    list = JSONUtil.ParseFormByJson <List <ServerInfo> >(json);
                }
            }
            catch (Exception ex)
            {
                Log("读取服务器配置文件server.json出错 " + ex.Message);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
            return(list);
        }
Beispiel #2
0
        /// <summary>
        /// 读取本地的配置文件信息
        /// </summary>
        /// <returns></returns>
        public static ConfigInfo GetConfigInfo()
        {
            string       path = Application.StartupPath.ToString() + "\\config.json";
            ConfigInfo   info = new ConfigInfo();
            string       json = string.Empty;
            StreamReader sr   = File.OpenText(path);

            try
            {
                json = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(json))
                {
                    info = JSONUtil.ParseFormByJson <ConfigInfo>(json);
                }
            }
            catch (Exception ex)
            {
                Log("读取配置文件config.json出错 " + ex.Message);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }


            return(info);
        }