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:
private void Readlog(string path) { StreamReader SR; string S; SR = File.OpenText(path); S = SR.ReadLine(); while (S != null) { if (S != null) { //this is sloppy but i cant have a trailing /r/n so this is the only //way i can think to get rid of it S = S + "\r\n"; } textBox1.AppendText(S); S = SR.ReadLine(); } SR.Close(); }
what i want to do is change it to something like
c# Code:
private string Readlog(string path) { string temp; StreamReader SR; string S ; SR = File.OpenText(path); S = SR.ReadLine(); temp =s while (S != null) { if (S != null) { S = S + "\r\n"; } temp = temp +S; S = SR.ReadLine(); } SR.Close(); return temp; }
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


Reply With Quote
