예제 #1
0
        private void Button1_Click_2(object sender, EventArgs e)
        {
            string filename = "fruit.txt";

            if (File.Exists(filename))
            {
                try
                {
                    File.AppendAllText(filename, " " + Fruits_textbox.Text);
                    fruit_button.Visible = true;
                    save_button.Visible  = false;
                    Fruits_textbox.Clear();
                    Fruits_textbox.Visible = false;
                    MessageBox.Show("File Updated successfully");
                }
                catch (IOException)
                {
                    MessageBox.Show("Error Reading from file", "error file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(filename + " does not exit", "file error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Fruits_textbox.Visible  = true;
            Fruits_textbox.ReadOnly = true;
            Fruits_textbox.Clear();
            string filename = "fruit.txt";

            if (File.Exists(filename))
            {
                StreamReader stream;
                try
                {
                    using (stream = new StreamReader(filename))
                    {
                        Fruits_textbox.AppendText(stream.ReadToEnd());
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show("Error Reading from file", "error file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(filename + " does not exit", "file error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 private void AddInformation_button_Click(object sender, EventArgs e)
 {
     Fruits_textbox.Visible  = true;
     Fruits_textbox.ReadOnly = false;
     Fruits_textbox.Clear();
     MessageBox.Show("Add Information option is enabled now", "Add Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     save_button.Visible = true;
 }