Hello.
I have an *.txt file on a Server.
i need a cod to Read the file and save the txt into a string array[23].
the txt in the txt-file is like this:
Hello
how
are
you?
and i want it in an string-arry (myarry)
so myarray[0] = Hello
myarray[1] = how
.
.
.
how to do? :D
P.S. i "download" the txt form the file with the WebClient funktion
Loading
VulpesPosted May 3, 2012, 11:13 AM
string[] separators = new string[]{"\r\n", "\n", "\r", "
", "
"};
string[] myarray = text.Split(separators, StringSplitOptions.None);
if(myarray.Length < 23)
{
Array.Resize(ref myarray, 23);
}
MaximilianPosted May 4, 2012, 6:57 AM
Jignesh TrivediPosted May 3, 2012, 12:09 AM
try following code
System.IO.StreamReader myFile = new System.IO.StreamReader("E:\\test.txt");
string myString;
while ((myString = myFile.ReadLine()) != null)
{
Console.WriteLine(myString);
}
Console.Read();
hope this help.