Newbie question;
How do I cast a text file to an array, after the file is read using StreamReader?

I have read many threads, code etc but I really need my hand held here, I just dont get it (especially using windows forms)...this is part of an assignment.... I've been going around in circle's over this for the last week...and I'm a desperate now.

Your help would be appreciated.

this code works as it is, but I don't have an array (not an arraylist cause no manipulation required)

string fileName = "";
        string name;
        string[] array = new string[8999];//initialize array and size of (NOT USED)

//int Count = 0;//set count to 0 to interate through file line by line for linear search

            OpenFileDialog OpenFile = new OpenFileDialog();//declare variable
            OpenFile.ShowDialog(); //show dialog box of files
            OpenFile.Filter = "Text files(*.txt)|*.txt|All files (*.*) | *.*"; //filter by these file  
            OpenFile.FilterIndex = 0;//show first file type?

            fileName = OpenFile.FileName;//declare variable
            if (OpenFile.ShowDialog() == DialogResult.OK)//if file found then display results to screen
                foreach (string content in OpenFile.FileNames)
                    TextReader sr = new StreamReader(content);//read file using streamreader

                    while ((name = sr.ReadLine()) != null)//read textreader variable line by line
8 Years
Discussion Span
Last Post by Paua

does some-one know what I'm doing wrong here?

foreach (string content in OpenFile.FileNames)//sends opened file to variable.
                    TextReader sr = new StreamReader(content);//supposed to read file via StreamReader
                    string contents = sr.ReadToEnd();
                    string[]myArray = (sr);
                    foreach (string gotya in     myArray )

Yeah...Worked it out!, most of the stuff I discovered right here in DaniWeb...all that after scolling the net for the past...ages(I won't give actual time spent going around in circles trying to work it out prior to coming to DaniWeb, way too embrassing).
Well now on to part 2, 3 and documentation OOPs.

so, after all that here it is

TextReader sr = new StreamReader(fileName);
                    string contents = sr.ReadToEnd();
                    string[]myArray = {contents};
                    foreach (string gotya in myArray)
                        txtBDisplayContents.Text = gotya;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.