israel
19-09-2007 , 00:25
Es facil, "archivo" es el path donde está el archivo, ej: "C:/texto.txt" y "a" es la linea que queremos leer. ej: 2.
public string leer_linea(string archivo, int a)
{
int i=0;
string s = "";
StreamReader txt = new StreamReader(archivo);
while (i < a)
{
s = txt.ReadLine();
i++;
}
return s;
}
Un ejemplo de llamada: Lee del archivo "C:\texto.txt" la linea numero "3"
textBox1.Text = leer_linea("C:\texto.txt",3);
public string leer_linea(string archivo, int a)
{
int i=0;
string s = "";
StreamReader txt = new StreamReader(archivo);
while (i < a)
{
s = txt.ReadLine();
i++;
}
return s;
}
Un ejemplo de llamada: Lee del archivo "C:\texto.txt" la linea numero "3"
textBox1.Text = leer_linea("C:\texto.txt",3);
