Example #1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                FolderBrowserDialog Dialogo = new FolderBrowserDialog();
                if (Dialogo.ShowDialog() == DialogResult.OK)
                {
                    string dato   = MiClase.ImprimirFormato();
                    int    tamaño = MiClase.arregloBicola.Length;
                    string nombreDelArchivo;
                    if (txtArchivo.Text == "")
                    {
                        nombreDelArchivo = "Cola";
                    }
                    else
                    {
                        nombreDelArchivo = txtArchivo.Text;
                    }

                    string ruta = Dialogo.SelectedPath + "\\" + nombreDelArchivo + ".txt";
                    using (var writer = new StreamWriter(ruta))
                    {
                        writer.Close();
                    }
                    string[] DatosYTamaño = { dato, tamaño + "" };
                    File.WriteAllLines(ruta, DatosYTamaño);
                    MessageBox.Show("Datos guardados en la ruta : " + ruta);
                }
            }
            catch
            {
                MessageBox.Show("Error al cargar los datos");
            }
        }