C-Sharp-Moment

This commit is contained in:
2022-10-18 14:28:33 -05:00
parent 97a084391c
commit 7e8bef6ba5
249 changed files with 2504 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
namespace lab5_4_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void writeNameButton_Click(object sender, EventArgs e)
{
try
{
// Declare a StreamWriter Variable.
StreamWriter outputFile;
// Create a file and get a StreamWriter object.
outputFile = File.CreateText("Friend.txt");
// Write the friend's name to the file.
outputFile.WriteLine(nameTextBox.Text);
// Close the file.
outputFile.Close();
// Let the user know the name was written.
MessageBox.Show("Wrote \"" + nameTextBox.Text + "\" to file.");
} catch (Exception ex) {
// Display an error message.
MessageBox.Show(ex.Message);
}
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}