how do i get this to work? how do i convert it from System.IO.Stream into a stringCode:StreamReader read;
read = new StreamReader(File.OpenRead("f:\\test.txt"));
this.TextBox1.Text = read;
Printable View
how do i get this to work? how do i convert it from System.IO.Stream into a stringCode:StreamReader read;
read = new StreamReader(File.OpenRead("f:\\test.txt"));
this.TextBox1.Text = read;
umm I believe you have to call a method or something. I dont do C# so I'm not 100% sure but try this:
this.TextBox1.Text = read.ReadLine();
:rolleyes:
yer thanks it worked :D
:)
i ve try to get it to read all the lines, but its says i cant convert and int to a bool? im not using an int, im using a string? or have i got totaly messed up somewhere?Code:StreamReader read = new StreamReader(File.OpenRead("F:\\test.txt"));
while(read.Read())
{
this.txtHosts.Text = this.txtHosts.Text + read.ReadLine() + (Char)13;
}
This is probably what you wanted to do..
Or, you can do this I think...Code:StreamReader re = File.OpenText(sFile);
string input = null;
while ((input = re.ReadLine()) != null)
{
this.txtHosts.Text += input;
}
re.Close();
Seems like this would make the most sense from what I see of your code. It reads in the whole file at once instead of looping.
Code:StreamReader sr = new StreamReader(
(System.IO.Stream)File.OpenRead("C:\\Temp\\Test.txt"),
System.Text.Encoding.ASCII);
sr.BaseStream.Seek(0, SeekOrigin.Begin);
this.txtHosts.Text =sr.ReadToEnd();
sr.Close();
well I actually had to do this in C#, yay! first time I used c#:DQuote:
Originally posted by john tindell
i ve try to get it to read all the lines, but its says i cant convert and int to a bool? im not using an int, im using a string? or have i got totaly messed up somewhere?Code:StreamReader read = new StreamReader(File.OpenRead("F:\\test.txt"));
while(read.Read())
{
this.txtHosts.Text = this.txtHosts.Text + read.ReadLine() + (Char)13;
}
Umm change your loop to this
while(read.Peek() != -1) { .....
thanks tonns :D