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. How to get name of a file opened by Open dialog box?

How to get name of a file opened by Open dialog box?

Scheduled Pinned Locked Moved C / C++ / MFC
questionarchitecturetutorial
6 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.
  • A Offline
    A Offline
    Azadeh
    wrote on last edited by
    #1

    Hi friends, How can I get the name of file which is opened by the user by means of open dialog box in a document/view architecture? Thank you, Azadeh

    J 1 Reply Last reply
    0
    • A Azadeh

      Hi friends, How can I get the name of file which is opened by the user by means of open dialog box in a document/view architecture? Thank you, Azadeh

      J Offline
      J Offline
      Jeff Patterson
      wrote on last edited by
      #2

      CFileDialog's GetPathName should work Jeff Patterson Programmers speak in Code. http://www.anti-dmca.org[^]

      A 2 Replies Last reply
      0
      • J Jeff Patterson

        CFileDialog's GetPathName should work Jeff Patterson Programmers speak in Code. http://www.anti-dmca.org[^]

        A Offline
        A Offline
        Azadeh
        wrote on last edited by
        #3

        Thank you! It worked well.

        1 Reply Last reply
        0
        • J Jeff Patterson

          CFileDialog's GetPathName should work Jeff Patterson Programmers speak in Code. http://www.anti-dmca.org[^]

          A Offline
          A Offline
          Azadeh
          wrote on last edited by
          #4

          I want to open it by myself to be able to read and write to and from it.

          J 1 Reply Last reply
          0
          • A Azadeh

            I want to open it by myself to be able to read and write to and from it.

            J Offline
            J Offline
            jhwurmbach
            wrote on last edited by
            #5

            Does CDocument::GetPathName() help you? < edit > OOps, did not read enough! You are asking if you can close the file opened by the framework. Probably the answer is 'depends'. Cant you simply override CDocument::OnOpenDocument() with your own load code? -- "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski

            A 1 Reply Last reply
            0
            • J jhwurmbach

              Does CDocument::GetPathName() help you? < edit > OOps, did not read enough! You are asking if you can close the file opened by the framework. Probably the answer is 'depends'. Cant you simply override CDocument::OnOpenDocument() with your own load code? -- "My opinions may have changed, but not the fact that I am right." Found in the sig of Herbert Kaminski

              A Offline
              A Offline
              Azadeh
              wrote on last edited by
              #6

              As you said , I overrided CDocument::OnOpenDocument() , but I simply open a text file and in that case this function isn't been called.I think it only opens files that are saved with serilizing and using CArchive and it doesn't open my text file.I used a text file to save graphic items that are drawn by the user in my project and I want user can open the file in a symbolic way then I draw the items using text file.However this is enough for me that I can get the name of file even if it hasn't opened really.I thought it opens file and I can not open it simultanously.But even for a file that is saved with the CArchive format, it seems that it opens the corresponding file and then close it because I can open the same file at that time.

              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