Ejemplo n.º 1
0
        private void BtnTestData001_Load_Click(object sender, EventArgs e)
        {
            //파일 읽기
            string sJson = File.ReadAllText(@"TestData001.json");
            //json문자열을 모델로 변환
            TestData001 tdTemp = JsonConvert.DeserializeObject <TestData001>(sJson);

            txtStrData1.Text     = tdTemp.StrData1.ToString();
            txtStrData2.Text     = tdTemp.StrData2.ToString();
            numericIntData1.Text = tdTemp.IntData1.ToString();
            numericIntData2.Text = tdTemp.IntData2.ToString();
        }
Ejemplo n.º 2
0
        private void BtnTestData001_Save_Click(object sender, EventArgs e)
        {
            TestData001 tdTemp = new TestData001();

            tdTemp.StrData1 = txtStrData1.Text;
            tdTemp.StrData2 = txtStrData2.Text;
            tdTemp.IntData1 = Convert.ToInt32(numericIntData1.Text);
            tdTemp.IntData2 = Convert.ToInt32(numericIntData2.Text);

            //모델을 json 문자열로 변환
            string sJson = JsonConvert.SerializeObject(tdTemp);

            //파일로 저장
            File.WriteAllText(@"TestData001.json", sJson);
        }