-
displaying to the screen
I am trying to display information back to my interface and dont know how to...I am really new to all this and I am stuck. What I was doing is:
Code:
try
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(@"C:\Code\somedoc.txt"))
{
String line;
line = sr.ReadLine();
System.Console.WriteLine(line);
sr.Close();
}
}
catch (Exception ex)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(ex.Message);
}
The problem is...it is not displaying anything on the interface...at the moment I dont care where on the interface it displays the result, I just want to make sure it displays.....Can anyone help.
Thanx
-
Make sure you loop you read routine for as long as the file has lines left... ;)
-
I cant even get it to display the first line :( let alone looping through the whole file.
System.Console.WriteLine(line); <--- I thought this would display at least the first line
If I could get it to show at least one line I'd be happy.
-
It works as expected for me. Make sure your file exists ( some error checking might be in order... ) and your console window stays open long enough to actually read what is printed.
-
I cant get it to display with System.Console.WriteLine(line) and I have no idea why...but if I do SpanMessage.InnerHtml = line then it displays the output to the screen. Any ideas as to why this happens.
-
I just opened a new console application and pasted your code into the main function. What kind of project do you have ?
-
What I am doing is, I have a screen which captures certain information and saves it all to a text file. Once it has been saved, a new process is created which starts up my c++ exe which in turn does a whole heap to the text file and writes certain data back to the text file.
When the exe has completed, my interface re-opens the text file and needs to display certain data, which had been placed in the text file by my exe, and approval by the user needs to be obtained.
All of this is working :D but for some unforsaken reason I cant get System.Console.WriteLine(line) to display :( I can only get SpanMessage.InnerHtml = line to display the data.
Could you tell me the difference between the two of these. I am very new at this and have come this far by doing alot of research and of course trial and error. I have litteraly come to the end of this long project and would love any insight you could give me.
Thanx for all your help so far.
-
Well, if you don't have a console project, I don't think Console.WriteLine will work. What kind of project is that ? Do you have a web project ? Seems as if you need another way to output your data.
-
Please find something and hit me over the head with it. It is a web page :rolleyes: how could I be so dense. Some times I surprise myself. If you hadn't of asked, I dont think it would have ever dawned on me.
Thanx again nvoigt for all your help.