Fork me on GitHub

读取配置文件返回键值对

        private Dictionary<string,string> ReadConfig()
        {
            try
            {
                using (FileStream fs = new FileStream("config.json", FileMode.Open))
                {
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        return JsonConvert.DeserializeObject<Dictionary<string, string>>(sr.ReadToEnd());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

                
        }

 

posted @ 2018-01-17 20:08  Something_Diffrent  阅读(287)  评论(0)    收藏  举报