jump to navigation

Reescribir un archivo de texto en C# 26 Julio 2008

Posted by joelperez in Microsoft, Programacion.
Tags: , ,
add a comment

using System;

using System.IO;

using System.Collections.Generic;

using System.Text;

 

namespace JoelTextReWriter

{

    class Program

    {

        static void Main(string[] args)

        {

            string Linea = “”;

            using (StreamWriter sw = new StreamWriter(“archivo_destino.txt”))

            {

                TextReader tr = new StreamReader(“archivo_origen.txt”);

                while ((Linea = tr.ReadLine()) != null)

                {

                    Console.WriteLine(Linea);

                    sw.WriteLine(Linea);

                }

                tr.Close();

            }

        }

    }

}