Thread: displaying to the screen

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    32

    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

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Make sure you loop you read routine for as long as the file has lines left...
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    32
    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.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    32
    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.

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    I just opened a new console application and pasted your code into the main function. What kind of project do you have ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    Registered User
    Join Date
    Jan 2004
    Posts
    32
    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 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.

  8. #8
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  9. #9
    Registered User
    Join Date
    Jan 2004
    Posts
    32
    Please find something and hit me over the head with it. It is a web page 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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Feedback: Functional Specification Wording
    By Ragsdale85 in forum C++ Programming
    Replies: 0
    Last Post: 01-18-2006, 04:56 PM
  2. char copy
    By variable in forum C Programming
    Replies: 8
    Last Post: 02-06-2005, 10:18 PM
  3. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. reading files and displaying them on screen
    By kendals in forum C Programming
    Replies: 4
    Last Post: 03-29-2002, 05:01 PM