コード例 #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            sfd.InitialDirectory = Directory.GetCurrentDirectory();
            DialogResult dr = sfd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                PathConfiguration pc         = new PathConfiguration("JDK8", "C\\Test\\LOUL");
                string            jsonString = JsonSerializer.Serialize(pc);
                File.WriteAllText(sfd.FileName, jsonString);
            }
        }
コード例 #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     txtbJdk.Text = Jdk;
     try
     {
         string            jsonString = File.ReadAllText("C:\\app\\JdkSwitcher\\JdkSwitcher\\Save.json");
         PathConfiguration pc         = JsonSerializer.Deserialize <PathConfiguration>(jsonString);
         comboBox1.Items.Add(pc);
     }
     catch (DirectoryNotFoundException ex)
     {
         Logger.Info(ex, "No configuration save found");
     }
     if (comboBox1.Items.Count > 0)
     {
         comboBox1.SelectedIndex = 0;
     }
 }