Click here to Skip to main content
15,914,500 members
Home / Discussions / C#
   

C#

 
GeneralRe: sql query Pin
falles0123-Aug-07 15:20
falles0123-Aug-07 15:20 
AnswerRe: sql query Pin
Vasudevan Deepak Kumar23-Aug-07 17:36
Vasudevan Deepak Kumar23-Aug-07 17:36 
GeneralRe: sql query Pin
Christian Graus23-Aug-07 18:16
protectorChristian Graus23-Aug-07 18:16 
Questionmicrsoft office + .NET Pin
shereem khaleel23-Aug-07 12:26
shereem khaleel23-Aug-07 12:26 
AnswerRe: micrsoft office + .NET Pin
Judah Gabriel Himango23-Aug-07 12:57
sponsorJudah Gabriel Himango23-Aug-07 12:57 
QuestionModifying text displayed in a webbrowser control Pin
Ahmad Zaidi23-Aug-07 10:59
Ahmad Zaidi23-Aug-07 10:59 
AnswerRe: Modifying text displayed in a webbrowser control Pin
ChrisKo23-Aug-07 11:58
ChrisKo23-Aug-07 11:58 
QuestionProblem with returning a string from a sub Pin
crash89323-Aug-07 9:36
crash89323-Aug-07 9:36 
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

private void Readlog(string path)<br />
        {<br />
            StreamReader SR;<br />
            string S;<br />
            SR = File.OpenText(path);<br />
            S = SR.ReadLine();<br />
            while (S != null)<br />
            {<br />
                if (S != null)<br />
                {<br />
                   //this is sloppy but i cant have a trailing /r/n so this is the only                <br />
                    //way i can think to get rid of it                    <br />
                   S = S + "\r\n";<br />
                }<br />
                textBox1.AppendText(S);<br />
                S = SR.ReadLine();<br />
            }<br />
            SR.Close();<br />
        }


what i want to do is change it to something like

private string Readlog(string path)<br />
        {<br />
            string temp;<br />
            StreamReader SR;<br />
            string S ;<br />
            SR = File.OpenText(path);<br />
            S = SR.ReadLine();<br />
            temp =s<br />
            while (S != null)<br />
            {<br />
                if (S != null)<br />
                {<br />
                    S = S + "\r\n";<br />
                }<br />
                temp = temp +S;<br />
                S = SR.ReadLine();<br />
            }<br />
            SR.Close();<br />
            return temp;<br />
        }




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
<br />
Foreach something in something<br />
{<br />
writelog(merge.txt,readlog(something.filename);<br />
}<br />
<br />

Thanks for pointing me in the right direction
AnswerRe: Problem with returning a string from a sub [modified] Pin
ChrisKo23-Aug-07 10:33
ChrisKo23-Aug-07 10:33 
GeneralRe: Problem with returning a string from a sub Pin
ChrisKo23-Aug-07 11:43
ChrisKo23-Aug-07 11:43 
GeneralRe: Problem with returning a string from a sub Pin
crash89323-Aug-07 12:12
crash89323-Aug-07 12:12 
GeneralRe: Problem with returning a string from a sub [modified] Pin
ChrisKo23-Aug-07 12:50
ChrisKo23-Aug-07 12:50 
QuestionDispose a thread? Pin
verlinden.nick@telenet.be23-Aug-07 9:07
verlinden.nick@telenet.be23-Aug-07 9:07 
AnswerRe: Dispose a thread? Pin
Judah Gabriel Himango23-Aug-07 13:01
sponsorJudah Gabriel Himango23-Aug-07 13:01 
GeneralRe: Dispose a thread? Pin
ChrisKo23-Aug-07 13:08
ChrisKo23-Aug-07 13:08 
GeneralRe: Dispose a thread? Pin
verlinden.nick@telenet.be24-Aug-07 2:27
verlinden.nick@telenet.be24-Aug-07 2:27 
AnswerRe: Dispose a thread? Pin
Luc Pattyn23-Aug-07 14:02
sitebuilderLuc Pattyn23-Aug-07 14:02 
GeneralRe: Dispose a thread? Pin
verlinden.nick@telenet.be24-Aug-07 2:31
verlinden.nick@telenet.be24-Aug-07 2:31 
GeneralRe: Dispose a thread? Pin
Luc Pattyn24-Aug-07 2:43
sitebuilderLuc Pattyn24-Aug-07 2:43 
GeneralRe: Dispose a thread? Pin
verlinden.nick@telenet.be24-Aug-07 9:08
verlinden.nick@telenet.be24-Aug-07 9:08 
GeneralRe: Dispose a thread? Pin
Luc Pattyn24-Aug-07 16:06
sitebuilderLuc Pattyn24-Aug-07 16:06 
GeneralRe: Dispose a thread? Pin
verlinden.nick@telenet.be25-Aug-07 2:04
verlinden.nick@telenet.be25-Aug-07 2:04 
QuestionContextMenuStrip and DataGridView Pin
FernandoMartin23-Aug-07 9:01
FernandoMartin23-Aug-07 9:01 
AnswerRe: ContextMenuStrip and DataGridView Pin
Judah Gabriel Himango23-Aug-07 13:08
sponsorJudah Gabriel Himango23-Aug-07 13:08 
Questionconvertion from pdf file into jpeg Pin
adilkazmi23-Aug-07 8:45
adilkazmi23-Aug-07 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.