コード例 #1
0
        private void EnterStationDataForm_Load(object sender, EventArgs e)
        {
            // load stationData.json
            if (File.Exists(stationDataFilePath))
            {
                // read stationdataFile
                try
                {
                    Encoding     utf8Enc = Encoding.GetEncoding("UTF-8");
                    StreamReader reader  = new StreamReader(
                        stationDataFilePath, utf8Enc);
                    string json = reader.ReadToEnd();
                    reader.Close();

                    StationData stationData = JsonConvert.DeserializeObject <StationData>(json);
                    // enter textBox
                    CallTextBox.Text         = stationData.Call;
                    NameTextBox.Text         = stationData.Name;
                    Address1TextBox.Text     = stationData.Address1;
                    Address2TextBox.Text     = stationData.Address2;
                    StateTextBox.Text        = stationData.State;
                    CityTextBox.Text         = stationData.City;
                    CountryTextBox.Text      = stationData.Country;
                    JCCNumTextBox.Text       = stationData.JCCNum;
                    GridSquareTextBox.Text   = stationData.GridSquare;
                    CQZoneTextBox.Text       = stationData.CQZone;
                    ITUZoneTextBox.Text      = stationData.ITUZone;
                    ClubTextBox.Text         = stationData.Club;
                    EmailAddressTextBox.Text = stationData.EmailAddress;
                }
                catch (UnauthorizedAccessException exc)
                {
                    System.Windows.Forms.MessageBox.Show("Fault to read staton data to " + stationDataFilePath + "\n" +
                                                         "Error : " + exc.Message + "\n" +
                                                         "Not have needed authorization.");
                }
                catch (IOException exc)
                {
                    System.Windows.Forms.MessageBox.Show("Fault to read staton data to " + stationDataFilePath + "\n" +
                                                         "Error : " + exc.Message + "\n" +
                                                         "May File is locked.");
                }
            }
        }