Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/12/2009, 17:43
REHome
 
Fecha de Ingreso: mayo-2007
Ubicación: PIC-16F84A
Mensajes: 729
Antigüedad: 17 años, 8 meses
Puntos: 8
Archivos de broma con C#

Hola:

Me ha enviado un archivo en CMD de broma que me llena los PenDrive de 8 GB a tope. En mi caso le quiero devolver la jugada en plan broma y lo único que se me ocurre es esto. Tarda en escribirse, pero él lo hacía más rapido que mi método. ¿Alguien le sale mejor?

Código:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO; // No olvidar desde aquí.

namespace CMD_Serie
{
    class Program
    {
        private const string FILE_NAME = "Archivo.txt";

        static void Main(string[] args)
        {
            if (File.Exists(FILE_NAME))
            {
                Console.WriteLine("{0} ya existe.", FILE_NAME);
                Console.ReadKey();
                return;
            }
            using (StreamWriter sw = File.CreateText(FILE_NAME))
            {
                for (long i = 1; i <= 999999999999999999; i++)
                {
                    Console.WriteLine(i);
                    sw.WriteLine(i);
                    //sw.Close();
                }
            }
        }
    }
}
Saludo.
__________________
Meta Shell, VERSIÓN 1.2.2
Descargar