Exemple #1
0
 public SetSysDto GetList()
 {
     if (!File.Exists(_path))
     {
         return(null);
     }
     try
     {
         string       json = "";
         FileStream   fs   = new FileStream(_path, FileMode.Open, FileAccess.Read);
         StreamReader sr   = new StreamReader(fs);
         string       str;
         while ((str = sr.ReadLine()) != null)
         {
             json += str;
         }
         sr.Close();
         fs.Close();
         SetSysDto ret = new SetSysDto
         {
             Json = json
         };
         return(ret);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #2
0
 public bool Add(SetSysDto input)
 {
     try
     {
         if (!File.Exists(_path))
         {
             FileStream   fs = new FileStream(_path, FileMode.Create, FileAccess.Write);
             StreamWriter sw = new StreamWriter(fs);
             sw.WriteLine(input.Json);
             sw.Close();
             fs.Close();
         }
         StreamWriter sr = new StreamWriter(_path);
         sr.WriteLine(input.Json);
         sr.Close();
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }