Thread: Automatically Open Text File

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    27

    Automatically Open Text File

    Hi,

    I am not sure where to ask this question, but here goes. I am working on a program that outputs to a text file. I can do this without any issues.

    My question is, how can I automatically open the text file at the end of the program to see its contents? It is tedious to switch to the directory and double-click it every time to open it.

    Thanks,
    JackR

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Do you care what platform you get a solution for?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    ShellExecute() (at the end)
    Enter the full path to the text file, and it will open it in the app you have chosen to view text files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    i think a cleaner solution would be to use a batch file (windows) or a shell script (everything else) to first run the program then display the file.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    27
    Thank you for the advice. Shell script it is.

    JackR

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Function is called and I am trying to open a file
    By tommy69 in forum C Programming
    Replies: 88
    Last Post: 05-06-2004, 08:33 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM