ReadAllText
y a ReadAllLines
por la ruta de acceso adecuada y el nombre de archivo en el equipo.If you are not using the text files from How to write to a text file, replace the argument to ReadAllText
and ReadAllLines
with the appropriate path and file name on your computer.myFile.cs
puede que no sea un archivo de código fuente de C#.For example, the file myFile.cs
might not be a C# source file.PeekChars
para determinar el formato de cada línea a medida que va analizando el archivo.You can process a file with multiple formats by using the PeekChars
method to determine the format of each line as you parse through the file.testfile.txt
:The following is the complete example that reads from the file testfile.txt
: