Skip to content

Instantly share code, notes, and snippets.

@Trochito
Created May 27, 2015 16:51
Show Gist options
  • Select an option

  • Save Trochito/8f3ee12a4c755ec3daf3 to your computer and use it in GitHub Desktop.

Select an option

Save Trochito/8f3ee12a4c755ec3daf3 to your computer and use it in GitHub Desktop.
Manejo de Archivos con Formularios en C# - básico 1
// WINDOWS FORMS
//CREAR UN ARCHIVO
private void buttonAccion_Click(object sender, EventArgs e)
{
StreamWriter Archivo;
Archivo = File.CreateText(textBoxNomArchivo.Text);
Archivo.Close();
MessageBox.Show("El archivo ha sido creado correctamente");
}
//ADICIONAR UNA FILA EN UN ARCHIVO
private void button2_Click(object sender, EventArgs e)
{
StreamWriter Archivo;
Archivo = File.AppendText(textBoxNomArchivo.Text);
Archivo.WriteLine(textBox1.Text);
Archivo.Close();
MessageBox.Show("La línea ha sido adicionada correctamente!!");
}
//ELIMINAR UN ARCHIVO
private void button3_Click(object sender, EventArgs e)
{
File.Delete(textBoxNomArchivo.Text);
MessageBox.Show("El archivo ha sido correctamente eliminado!!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment