Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help!automatically read the file

Help!automatically read the file

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jfk_lili
    wrote on last edited by
    #1

    Hi guys, is there any method for retrieve the previose opend file (in the last excution of the program)when the program just being start again? sorry for my english.... what i want is... my program has opened a text file, let's say data10.txt... then close the program .. open it, then the program while automatically the data10.txt which it has read last time the file is a text file, so cannot use serializing.:) thank u in advance!!!!!!!!!!

    M S 2 Replies Last reply
    0
    • J jfk_lili

      Hi guys, is there any method for retrieve the previose opend file (in the last excution of the program)when the program just being start again? sorry for my english.... what i want is... my program has opened a text file, let's say data10.txt... then close the program .. open it, then the program while automatically the data10.txt which it has read last time the file is a text file, so cannot use serializing.:) thank u in advance!!!!!!!!!!

      M Offline
      M Offline
      mirex
      wrote on last edited by
      #2

      I dont think that program can do it by itself. You should write the filename into some file (for example 'lastfile.dat') on program exit, and when program starts read the filename from 'lastfile.dat' and open it.

      1 Reply Last reply
      0
      • J jfk_lili

        Hi guys, is there any method for retrieve the previose opend file (in the last excution of the program)when the program just being start again? sorry for my english.... what i want is... my program has opened a text file, let's say data10.txt... then close the program .. open it, then the program while automatically the data10.txt which it has read last time the file is a text file, so cannot use serializing.:) thank u in advance!!!!!!!!!!

        S Offline
        S Offline
        Steve S
        wrote on last edited by
        #3

        You will need to save the last filename used somewhere, like the registry, in HKCU\Software\jfk_lili\appname\LastFile, for example. Then on startup, you need a mechanism to detect that the program had no arguments, and then force it to load that file. If you were using MFC, for instance, you could override your InitInstance to examine the program's command line, where it uses CCommandLineInfo, and if the verb was FileNew, change it to FileOpen and fill in the m_strFileName member. You then call ProcessShellCommand, and it happens automatically. Steve S Developer for hire

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups