Ejercicio_7
*FileStream
*StreamReader
*Separar campos con '/'
Codigo (main.cs) :
using System;
using System.IO;
namespace ejercicio_7
{
class MainClass
{
static string [,] autobus= new string [9,3];
public static void Main (string[] args)
{
FileStream f= null;
StreamReader reader=null;
int i ;
i=0;
string renglon;
string[] temp;
string path = "/home/daniel/Projects/ejercicio_7/ejercicio_7/bin/Debug/carta.txt";
f = new FileStream((path),FileMode.Open,FileAccess.Read);
reader= new StreamReader(f);
while (reader.Peek() != -1)
{
renglon=reader.ReadLine();
char[] delimitator1 = new char[] { '/' };
temp = renglon.Split(delimitator1);
autobus[i, 0] = temp[0];
autobus[i, 1] = temp[1];
autobus[i, 2] = temp[2];
i = i + 1;
}
reader.Close();
for(i=0;i<=2;i++)
{
Console.WriteLine(autobus[i,0] + " " + " " + autobus[i,1] + " " + " " + autobus[i,2] );
}
}
}
}
using System.IO;
namespace ejercicio_7
{
class MainClass
{
static string [,] autobus= new string [9,3];
public static void Main (string[] args)
{
FileStream f= null;
StreamReader reader=null;
int i ;
i=0;
string renglon;
string[] temp;
string path = "/home/daniel/Projects/ejercicio_7/ejercicio_7/bin/Debug/carta.txt";
f = new FileStream((path),FileMode.Open,FileAccess.Read);
reader= new StreamReader(f);
while (reader.Peek() != -1)
{
renglon=reader.ReadLine();
char[] delimitator1 = new char[] { '/' };
temp = renglon.Split(delimitator1);
autobus[i, 0] = temp[0];
autobus[i, 1] = temp[1];
autobus[i, 2] = temp[2];
i = i + 1;
}
reader.Close();
for(i=0;i<=2;i++)
{
Console.WriteLine(autobus[i,0] + " " + " " + autobus[i,1] + " " + " " + autobus[i,2] );
}
}
}
}
Salida:
Archivo TXT
No hay comentarios:
Publicar un comentario