Example #1
0
        private void guardarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileName;

            if (abrirArchivo.FileName != "")
            {
                fileName = this.abrirArchivo.FileName;
                switch (Path.GetExtension(fileName))
                {
                case ".txt":
                    PuntoTxt archivoTxt = new PuntoTxt();
                    archivoTxt.Guardar(fileName, this.rtbTexto.Text);
                    break;

                case ".dat":
                    PuntoDat archivoDat = new PuntoDat();
                    archivoDat.Contenido = this.rtbTexto.Text;
                    archivoDat.Guardar(fileName, archivoDat);
                    break;
                }
            }
            else
            {
                this.guardarComoToolStripMenuItem_Click(sender, e);
            }
        }
Example #2
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
                //Ejercicio 58
                switch (openFileDialog.FilterIndex)
                {
                case 1:
                    richTextBoxText.Text = new PuntoTxt().Leer(path);
                    break;

                case 2:
                    PuntoDat puntoDat = new PuntoDat();
                    puntoDat             = puntoDat.Leer(path);
                    richTextBoxText.Text = puntoDat.Contenido;
                    break;
                }
                //Ejercicio 56

                /*StreamReader sr = new StreamReader(path);
                 * richTextBoxText.Text = sr.ReadToEnd();
                 * sr.Close();*/
            }
        }
Example #3
0
        private void archivoMenuAbrir_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();

            open.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            open.Filter           = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";
            if (open.ShowDialog() == DialogResult.OK)
            {
                path = open.FileName;
                if (open.DefaultExt == "dat")
                {
                    PuntoDat pd = new PuntoDat();
                    pd.Contenido = richTextBox1.Text;
                    pd.Leer(path);
                }
                else if (open.DefaultExt == "txt")
                {
                    PuntoTxt pt = new PuntoTxt();
                    pt.Leer(path);
                }
                else
                {
                    MessageBox.Show("Error", "Elija otro formato", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                /*path = open.FileName;
                 * StreamReader sr = new StreamReader(open.FileName);
                 * richTextBox1.Text = sr.ReadToEnd();
                 * sr.Close();*/
            }
        }
Example #4
0
        private void GuardarComo()
        {
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = saveFileDialog.FileName;
                switch (saveFileDialog.FilterIndex)
                {
                case 1:
                    new PuntoTxt().GuardarComo(path, richTextBoxText.Text);
                    break;

                case 2:
                    PuntoDat puntoDat = new PuntoDat();
                    puntoDat.Contenido = richTextBoxText.Text;
                    puntoDat.Guardar(path, puntoDat);
                    break;
                }
            }
        }
Example #5
0
        private void Guardar()
        {
            //Ejercicio 58
            switch (Path.GetExtension(path))
            {
            case ".txt":
                new PuntoTxt().Guardar(path, richTextBoxText.Text);
                break;

            case ".dat":
                PuntoDat puntoDat = new PuntoDat();
                puntoDat.Contenido = richTextBoxText.Text;
                puntoDat.Guardar(path, puntoDat);
                break;
            }

            //Ejercicio 56
            //StreamWriter sw = new StreamWriter(path);
            //sw.Write(richTextBoxText.Text);
            //sw.Close();
        }
Example #6
0
        private void archivoMenuGuardarComo_Click(object sender, EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();

            save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            save.Filter           = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";
            if (save.ShowDialog() == DialogResult.OK)
            {
                path = save.FileName;
                if (save.DefaultExt == "dat")
                {
                    PuntoDat pd = new PuntoDat();
                    pd.Contenido = richTextBox1.Text;
                    pd.GuardarComo(path, pd);
                }

                /*StreamWriter sw = new StreamWriter(save.FileName);
                 * sw.Write(richTextBox1.Text);
                 * sw.Close();*/
            }
        }
Example #7
0
        private void guardarComoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileName;

            if (guardarArchivo.ShowDialog() == DialogResult.OK)
            {
                fileName = this.guardarArchivo.FileName;
                switch (Path.GetExtension(fileName))
                {
                case ".txt":
                    PuntoTxt archivoTxt = new PuntoTxt();
                    archivoTxt.Guardar(fileName, this.rtbTexto.Text);
                    break;

                case ".dat":
                    PuntoDat archivoDat = new PuntoDat();
                    archivoDat.Contenido = this.rtbTexto.Text;
                    archivoDat.Guardar(fileName, archivoDat);
                    break;
                }
            }
        }
Example #8
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileName;

            if (abrirArchivo.ShowDialog() == DialogResult.OK)
            {
                fileName = abrirArchivo.FileName;
                switch (Path.GetExtension(fileName))
                {
                case ".txt":
                    PuntoTxt archivoTxt = new PuntoTxt();
                    this.rtbTexto.Text = archivoTxt.Leer(fileName);
                    break;

                case ".dat":
                    PuntoDat archivoDat = new PuntoDat();
                    archivoDat         = archivoDat.Leer(fileName);
                    this.rtbTexto.Text = archivoDat.Contenido;
                    break;
                }
            }
        }