0

Possible Duplicate:
C# how to convert File.ReadLines into string array?

I have a text file that I want to make a String array from. The file is newline delimited. For example,

entry1

entry2

entry3

will make an array of {"entry1", "entry2", "entry3"}

EDIT: I am wanting to do this using DownloadString in WebClient

Community
  • 1
  • 1
  • 1
    Check this out http://stackoverflow.com/questions/4220993/c-sharp-how-to-convert-file-readlines-into-string-array – Vincent James Jan 26 '13 at 03:19
  • 1
    http://stackoverflow.com/questions/1271225/c-sharp-reading-a-file-line-by-line Google things first before asking or check SO questions – Deepankar Bajpeyi Jan 26 '13 at 03:19
  • 2
    Problem is that I doing this using the DownloadString method in WebClient and I want to avoid downloading it to a temp dir. – Zachster1996 Jan 26 '13 at 03:27

1 Answers1

3

So you're just trying to split a string into an array that is delimited with a new line?

If so, this should work:

string temp = webClient.DownloadString(someurl);
string[] lines = temp.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

Good luck.

sgeddes
  • 62,311
  • 6
  • 61
  • 83