This example program specifies a file on the disk. ReadAllLines() gets a string array from the file. The string array returned can be used as any other string array.
using System;
using System.IO;
class Program
{
static void Main()
{
string[] lines = File.ReadAllLines(
"C:\\rearrange.txt");
Console.WriteLine(
"Length: {0}", lines.Length);
Console.WriteLine(
"First: {0}", lines[0]);
int count = 0;
foreach (string line in lines)
{
count++;
}
int c = 0;
for (int i = 0; i < lines.Length; i++)
{
c++;
}
Console.WriteLine(
"Count: {0}", count);
Console.WriteLine(
"C: {0}", c);
}
}
Length: 430
First: /_1=D1
Count: 430
C: 430