BenZilla wrote:
My noobness has caught up with me

Just trying to read a txt file stream and then put it in a multiline textbox. Here's some sample code

Stream myStream;
//open filedialog stuff.
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if ((myStream = openFileDialog1.OpenFile()) != null)
{
string sPythonString = Convert.ToString(myStream);
txtInputScript.Text = sPythonString;
}
So i'm thinking, great

But when I open up the text file this is all I get is this in the textbox.
System.IO.FileStream
A stream is not a string - it's a wrapper object around a stream of data, and as such you can't just cast it to a string. Convert.ToString() is the equivalent of calling myStream.ToString(), which (for most objects) simply returns the type name for lack of anything better.
What you need to do is read the text from the stream. Simplest way (in Framework v1.1) is this:
<BR>using (StreamReader reader = new StreamReader(myStream))<BR>{<BR> string sPythonString = reader.ReadToEnd();<BR> txtInputScript.Text = sPythonString;<BR>}To make things even simpler, you can simply pass the path to the file directly to the StreamReader constructor and have it implicitly create a FileStream.
In .NET 2.0 it's even simpler - ridiculously so, in fact:
<BR>string sPythonString = System.IO.File.ReadAllText(fileName);<BR>