ainn roes

ainn roes

  • NA
  • 1
  • 5.6k

transfer data from textbox to streamreader

Apr 7 2011 7:42 AM
i am new with c#
usually i use streamreader to display data in textbox
now...i want to read data from textbox to streamreader
i use this code but nothing will display
it is no error and i can trace it

 string retValue = null;
            string filename = ContentBox.Text;
            if (File.Exists(filename))
            {
                using (StreamReader fileReader = new StreamReader(filename))
                {
                    string fileRow;
                    while ((fileRow = fileReader.ReadLine()) != null)
                    {
                        string[] fileDataField = fileRow.Split(new string[] { "\r\n\t", " " }, StringSplitOptions.RemoveEmptyEntries);
                        string ListSplitLineByLine = "";
                        foreach (string lineByLine in fileDataField)
                        {
                            ListSplitLineByLine += "\r\n" + lineByLine;
                        }
                        if (!String.IsNullOrEmpty(ListSplitLineByLine))
                        {
                            retValue = ListSplitLineByLine.Trim();
                            txtCaseInputs.Text = retValue;
                            GenCombItems();
                        }
                        else
                        {
                            MessageBox.Show("No data");
                        }
                    }
                    // Line below is not necessary. Handled by the "using" clause.
                    // fileReader.Close();
                }
            }
            else
            {
                MessageBox.Show("File Not Found");
            }
            return retValue;

how can i solve this problem?can someone help me,please?

Answers (1)