Hi all

I have a sub that writes to a textbox in the code. I want to change it so it just returns as a string so i can use it over again for other stuff in the program


the current code is this

c# Code:
  1. private void Readlog(string path)
  2.         {
  3.             StreamReader SR;
  4.             string S;
  5.             SR = File.OpenText(path);
  6.             S = SR.ReadLine();
  7.             while (S != null)
  8.             {
  9.                 if (S != null)
  10.                 {
  11.                    //this is sloppy but i cant have a trailing /r/n so this is the only                
  12.                     //way i can think to get rid of it                    
  13.                    S = S + "\r\n";
  14.                 }
  15.                 textBox1.AppendText(S);
  16.                 S = SR.ReadLine();
  17.             }
  18.             SR.Close();
  19.         }

what i want to do is change it to something like

c# Code:
  1. private string Readlog(string path)
  2.         {
  3.             string temp;
  4.             StreamReader SR;
  5.             string S ;
  6.             SR = File.OpenText(path);
  7.             S = SR.ReadLine();
  8.             temp =s
  9.             while (S != null)
  10.             {
  11.                 if (S != null)
  12.                 {
  13.                     S = S + "\r\n";
  14.                 }
  15.                 temp = temp +S;
  16.                 S = SR.ReadLine();
  17.             }
  18.             SR.Close();
  19.             return temp;
  20.         }



The problem is that it always returns a null or just one line of text and i know its probably somthing right in front of me but I can't seem to figure out what it is

the idea is that i can use it in something like textbox1.text = readlog(c:\test)

or

Foreach something in something
{
writelog(merge.txt,readlog(something.filename);
}


Thanks for pointing me in the right direction