Hi All!
I am writing an app in C#.
I need to be able to display text (.txt) files created by the app in dialog boxes.
I can do this in vb.net all day long, but cannot find reference for doing so in C# .NET.
If someone could please, PLEASE point me in the right direction, I would greatly appreciate it.
Thanks!
Gary

Brick wall reached...assistance needed
MichMash
I therefore haven't a clue why a TextBox should be mistaken for the console!
to my knowledge textBox.Text = "file content" might only give some unreadible tokens in those cases where the text uses CRLF in stead of only CR which could be remidied with a simple sustitution (string.Replace(..) method)
Transferal to the console( ) I hardly ever start applications from a console, so probably didn't notice because of this. But perhaps we spot something when we view the code.
thompson16
Any suggestions
Chibuzo
Joseph Fluckiger
why doesn't frm.TextBoxName.Text = the contents of the text file stream
work
Balascandent
If you are still stuck, post an example in a new thread and I'll be happy to help you figure it out.
-Paul
smitaB
private void seeReadings()
{
string path = @"C:\readings.txt";
using (StreamReader sr = new StreamReader(path))
{
string txt = "",s;
while ((s = sr.ReadLine()) != nulll)
txt += s + "\n";
textbox.Text = txt;
}
}
The Sample (console app!) shows use of an sr.Peek() to test for the end of file, I used the while type loop above, though this might be on a TextReader. There are several options here.
In case you want to print on other controls you might concider:
<strong>Graphics g = control.CreateGraphics()</strong>
and use:
<strong>g.DrawString(....)</strong>
to draw on that control meanwhile reading taxt from the file. I do think some experimentation of your own might be more benificial for you.
good luck, hope this helps.
Samuel_zhang
private void seeReadings()
{
string path = @"C:\readings.txt";
using (StreamReader sr = new StreamReader(path))
{
sr.ReadToEnd();
}
}