Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/06/2010, 13:27
Avatar de gedarufi
gedarufi
 
Fecha de Ingreso: diciembre-2008
Ubicación: Colombia
Mensajes: 540
Antigüedad: 16 años, 3 meses
Puntos: 22
Respuesta: Ayuda FileStream y StreamReader en C#

Intenta con esto
Código C#:
Ver original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace ConsoleApplication
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             FileStream Archivo = new FileStream(@"C:\Users\German\Desktop\Leer.txt", FileMode.Open, FileAccess.ReadWrite);
  14.             StreamReader Lectura = new StreamReader(Archivo);
  15.            
  16.             float Promedio = 0;
  17.             float Suma = 0;
  18.             List<int> Numeros = new List<int>();
  19.             String lectura = String.Empy;
  20.  
  21.             while (lectura != null)
  22.             {
  23.                 lectura = Lectura.ReadLine();
  24.                 Numeros.Add(int.Parse(lectura));
  25.                 Suma = Suma + Numeros[Numeros.Count - 1];
  26.             }
  27.             Promedio = Suma / Numeros.Count;
  28.             Archivo.Close();
  29.             Lectura.Close();
  30.             Console.WriteLine("Se ecntraron {0} Elementos con una suma de {1} y Promedio {2:F} ",Numeros.Count,Suma,Promedio);
  31.             Console.ReadKey();
  32.         }
  33.     }
  34. }