Exemple #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         Business.SetFolderPath(Application.StartupPath);
         _tempfile = System.IO.Path.Combine(Application.StartupPath, _tempfile);
         if (System.IO.File.Exists(_tempfile))
         {
             string str = System.IO.File.ReadAllText(_tempfile);
             if (!string.IsNullOrEmpty(str))
             {
                 try
                 {
                     _dtotemp = Newtonsoft.Json.JsonConvert.DeserializeObject <DTOTemp>(str);
                 }
                 catch
                 {
                     _dtotemp = default(DTOTemp);
                 }
             }
         }
         if (_dtotemp != null)
         {
             txtChooseJson.Text = _dtotemp.JsonPath;
             txtChooseLog.Text  = _dtotemp.LogPath;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
        private void SaveTemp()
        {
            _dtotemp          = new DTOTemp();
            _dtotemp.JsonPath = txtChooseJson.Text;
            _dtotemp.LogPath  = txtChooseLog.Text;
            string str = Newtonsoft.Json.JsonConvert.SerializeObject(_dtotemp);

            if (System.IO.File.Exists(_tempfile))
            {
                System.IO.File.Delete(_tempfile);
            }
            System.IO.File.AppendAllText(_tempfile, str, Encoding.UTF8);
        }