Ejemplo n.º 1
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.path        = openFileDialog.FileName;
                this.tipoArchivo = openFileDialog.FilterIndex;
                switch (this.tipoArchivo)
                {
                case 1:
                {
                    PuntoTxt archivo = new PuntoTxt();
                    this.rchtbCajaDetexto.Text = archivo.Leer(this.path);
                    break;
                }

                case 2:
                {
                    PuntoDat archivo = new PuntoDat();
                    this.rchtbCajaDetexto.Text = (archivo.Leer(this.path)).Contenido;
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Title            = "Open Text File";
            openFile.Filter           = "TXT files|*.txt|DAT files|*.dat";
            openFile.InitialDirectory = @"C:\";
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                ruta = openFile.FileName.ToString();
                switch (openFile.FilterIndex)
                {
                case 1:     //selected .txt
                    PuntoTxt leerTxt = new PuntoTxt();
                    richTextBox1.Text = leerTxt.Leer(openFile.FileName);
                    break;

                case 2:     //selected .dat
                    PuntoDat leerDat = new PuntoDat();
                    leerDat           = leerDat.Leer(openFile.FileName);
                    richTextBox1.Text = leerDat.Contenido;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fileContent = string.Empty;
            string filePath    = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    filePath = openFileDialog.FileName;
                    try
                    {
                        if (Path.GetExtension(filePath) == ".txt")
                        {
                            PuntoTxt ptxt = new PuntoTxt();
                            richTextBox.Text = ptxt.Leer(filePath);
                        }
                        else
                        {
                            PuntoDat pdat = new PuntoDat();
                            pdat             = pdat.Leer(filePath);
                            richTextBox.Text = pdat.Contenido;
                        }
                        ultimoArchivoAbierto = filePath;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = @"C:\Users\Nacho\source\repos\Ejercicio 58";                                   //ruta de inicio, desp puedo elegir la que quiera
            openFileDialog.Filter           = "all files (*.*)|*.*|txt files (*.txt)|*.txt|archivos de datos (*.dat)|*.dat"; //tipo de archivo que puedo abrir

            try
            {
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    path = openFileDialog.FileName;
                    if (Path.GetExtension(path) == ".txt")
                    {
                        richTextBox.Text = puntoTxt.Leer(path);
                    }
                    else if (Path.GetExtension(path) == ".dat")
                    {
                        puntoDat         = puntoDat.Leer(path);
                        richTextBox.Text = puntoDat.Contenido;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 5
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //StreamReader sr;

            PuntoTxt archivoTxt = new PuntoTxt();
            PuntoDat archivoDat = new PuntoDat();


            //Muestra una ventana para seleccionar el archivo
            OpenFileDialog abrir = new OpenFileDialog();

            abrir.Filter = "Archivos de texto (*.txt)|*.txt|Archivos de datos (*.dat)|*.dat";

            if (abrir.ShowDialog() == DialogResult.OK)
            {
                this.PathArchivo = abrir.FileName;

                switch (abrir.FilterIndex)
                {
                case 1:    //texto
                    rtbEditorDeTexto.Text = archivoTxt.Leer(this.PathArchivo);
                    break;

                case 2:    //binario
                    //Guardo el .dat en una variable
                    archivoDat = archivoDat.Leer(this.PathArchivo);
                    //Leo el texto que está en la propiedad contenido
                    rtbEditorDeTexto.Text = archivoDat.Contenido;
                    break;
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// EventHandler of Open Button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1        = new OpenFileDialog();
     openFileDialog1.Title  = "Select a File";
     openFileDialog1.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string file = openFileDialog1.FileName;
         lastFilePath = file;
         MessageBox.Show($"{lastFilePath}");
         try {
             if (Path.GetExtension(lastFilePath) == ".txt")
             {
                 rtbText.Text = txtManager.Leer(lastFilePath);
             }
             else if (Path.GetExtension(lastFilePath) == ".dat")
             {
                 datManager   = datManager.Leer(lastFilePath);
                 rtbText.Text = datManager.Contenido;
             }
         } catch (ArchivoIncorrectoException ai) {
             MessageBox.Show($"Excepcion: {ai.Message}");
         }
     }
 }
Ejemplo n.º 7
0
        private void stripAbrir_OnClick(object sender, EventArgs e)
        {
            OpenFileDialog abrir = new OpenFileDialog();

            abrir.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            abrir.Filter           = "Archivos de texto (*.txt)|*.txt|Archivos de datos (*.dat)|*.dat";

            if (abrir.ShowDialog() == DialogResult.OK)
            {
                this.path = abrir.FileName;

                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto1 = new PuntoTxt();

                    this.richTextBox1.Text = texto1.Leer(this.path);
                }
                else
                {
                    PuntoDat texto = new PuntoDat();

                    this.richTextBox1.Text = texto.Leer(this.path).Contenido;
                }
            }
        }
Ejemplo n.º 8
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ventana = new OpenFileDialog();

            ventana.Filter = "Archivos de texto(.txt)|*.txt|Archivos de datos (.dat)|*.dat|Archivos XML(.xml)|*.xml";

            if (ventana.ShowDialog() == DialogResult.OK)
            {
                nombreArchivo = ventana.FileName;
                MessageBox.Show(ventana.FilterIndex.ToString());

                switch (ventana.FilterIndex)
                {
                case 1:
                    richTextBox1.Text = archivoTxt.Leer(ventana.FileName);
                    break;

                case 2:
                    archivoDat        = archivoDat.Leer(ventana.FileName); //REVISAR
                    richTextBox1.Text = archivoDat.Contenido;
                    break;

                case 3:
                    richTextBox1.Text = archivoXml.Leer(ventana.FileName);     //REVISAR
                    break;
                }
            }
            else
            {
                this.guardarComoToolStripMenuItem1_Click(sender, e);
            }
        }
Ejemplo n.º 9
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Lectura del archivo.
            PuntoTxt txt = new PuntoTxt();
            PuntoDat dat = new PuntoDat();

            if (TextEditor._openFileMenu.ShowDialog() == DialogResult.OK)
            {
                this._lastFilePath = TextEditor._openFileMenu.FileName;
                try
                {
                    if (this._lastFilePath.EndsWith(".txt"))
                    {
                        this.richTextBox1.Text = txt.Leer(this._lastFilePath);
                    }
                    else
                    {
                        this.richTextBox1.Text = dat.Leer(this._lastFilePath).Contenido;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("FATAL ERROR");
                }
            }
        }
Ejemplo n.º 10
0
        private void textoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofdAbrir.ShowDialog() == DialogResult.OK)
            {
                this.path = ofdAbrir.FileName;
            }
            else
            {
                return;
            }
            PuntoTxt archivo = new PuntoTxt();

            rtbEditor.Text = archivo.Leer(path);
            this.tipo      = "texto";
        }
Ejemplo n.º 11
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "txt files (*.txt)|*.txt|dat files (*.dat)|*.dat|All files (*.*)|*.*";
            ofd.ShowDialog();
            rutaArchivoActual = ofd.FileName;

            if (Path.GetExtension(rutaArchivoActual) == ".txt")
            {
                PuntoTxt stream = new PuntoTxt();
                rtb_texto.Text = stream.Leer(rutaArchivoActual);
            }
            if (Path.GetExtension(rutaArchivoActual) == ".dat")
            {
                PuntoDat stream = new PuntoDat().Leer(rutaArchivoActual);
                rtb_texto.Text = stream.Contenido;
            }
        }
Ejemplo n.º 12
0
        private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ofd.Filter = "Archivos de texto (*.txt)|*.txt|Archivos de datos (*.dat)|*.dat";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                switch (ofd.FilterIndex)
                {
                case 0:

                    rtbTexto.Text = txt.Leer(ofd.FileName);
                    break;

                case 1:
                    dat           = dat.Leer(ofd.FileName);
                    rtbTexto.Text = dat.Contenido;
                    break;
                }
                guardarToolStripMenuItem.Enabled = true;
            }
        }
Ejemplo n.º 13
0
 private void abrirToolStripMenuItem_Click(object sender, EventArgs e)
 {
     abrirArchivo        = new OpenFileDialog();
     abrirArchivo.Filter = "txt files(*.txt)|*.txt|dat files(*.dat)|*.dat";
     if (abrirArchivo.ShowDialog() == DialogResult.OK)
     {
         string ruta = abrirArchivo.FileName;
         if (Path.GetExtension(ruta) == ".txt")
         {
             txt = new PuntoTxt();
             richTextBox1.Text = txt.Leer(ruta);
         }
         else
         {
             dat = new PuntoDat();
             dat = dat.Leer(ruta);
             richTextBox1.Text = dat.Contenido;
         }
     }
 }
Ejemplo n.º 14
0
        public void Abrir()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = (this.path == null) ? AppDomain.CurrentDomain.BaseDirectory : this.path;
            dialog.Filter           = "Archivos de texto (.txt)|*.txt|Archivos de datos (.dat)|*.dat";

            if (DialogResult.OK == dialog.ShowDialog())  //si click cancel no entra
            {
                this.path = dialog.FileName;
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt puntoTxt = new PuntoTxt();
                    richTextBox1.Text = puntoTxt.Leer(this.path);
                }
                else if (Path.GetExtension(this.path) == ".dat")
                {
                    PuntoDat puntoDat = new PuntoDat();
                    puntoDat          = puntoDat.Leer(this.path);
                    richTextBox1.Text = puntoDat.Contenido;
                }
            }
        }
Ejemplo n.º 15
0
        public void Abrir()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.InitialDirectory = (this.path == null) ? AppDomain.CurrentDomain.BaseDirectory : this.path;
            dialog.Filter           = "Archivos de texto (.txt)|*.txt|Archivos de datos (.dat)|*.dat";

            if (DialogResult.OK == dialog.ShowDialog())
            {
                this.path = dialog.FileName;
                if (Path.GetExtension(this.path) == ".txt")
                {
                    PuntoTxt texto = new PuntoTxt();
                    rtbTexto.Text = texto.Leer(this.path);
                }
                else if (Path.GetExtension(this.path) == ".dat")
                {
                    PuntoDat binario = new PuntoDat();
                    binario       = binario.Leer(this.path);
                    rtbTexto.Text = binario.Contenido;
                }
            }
        }