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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Saving/Copying a file.

Saving/Copying a file.

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasehelp
8 Posts 4 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
    a3gupta
    wrote on last edited by
    #1

    Hello, I have dialog based application in VC++ 6.0. I need to copy a file to a user specified location. So I am making a button, when clicked by user, would just ask for the path that they want copy the file to. They don't need to specify the name of them file. It is a default database file. After they specify the path I need to copy the database file to that location. I don't know how exactly I should implement it. I couldn't really find any function that will make a copy of a file to a specified location. What control and functions do I need to use. Thanks for helping me with this basic problem.!! I really appreciate it. Sincerey, Anjum.

    J J A 3 Replies Last reply
    0
    • A a3gupta

      Hello, I have dialog based application in VC++ 6.0. I need to copy a file to a user specified location. So I am making a button, when clicked by user, would just ask for the path that they want copy the file to. They don't need to specify the name of them file. It is a default database file. After they specify the path I need to copy the database file to that location. I don't know how exactly I should implement it. I couldn't really find any function that will make a copy of a file to a specified location. What control and functions do I need to use. Thanks for helping me with this basic problem.!! I really appreciate it. Sincerey, Anjum.

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

      For the dialog to select the Path you could use SHBrowseForFolder X| , or better look here at CP for a really useable replacement. And what is wrong with ::CopyFile()/::CopyFileEx()?

      A 1 Reply Last reply
      0
      • A a3gupta

        Hello, I have dialog based application in VC++ 6.0. I need to copy a file to a user specified location. So I am making a button, when clicked by user, would just ask for the path that they want copy the file to. They don't need to specify the name of them file. It is a default database file. After they specify the path I need to copy the database file to that location. I don't know how exactly I should implement it. I couldn't really find any function that will make a copy of a file to a specified location. What control and functions do I need to use. Thanks for helping me with this basic problem.!! I really appreciate it. Sincerey, Anjum.

        J Offline
        J Offline
        Joan M
        wrote on last edited by
        #3

        use this: ::CopyFile(csOrigen,csDesti,TRUE) where csOrigen is the source path (CString), csDesti is the destination path (CString too), and the last BOOL parameter is a flag that defines if you want the operation to fail if the file exists. Take a look at the MSDN for further information...

        https://www.robotecnik.com freelance robots, PLC and CNC programmer.

        A 1 Reply Last reply
        0
        • J jhwurmbach

          For the dialog to select the Path you could use SHBrowseForFolder X| , or better look here at CP for a really useable replacement. And what is wrong with ::CopyFile()/::CopyFileEx()?

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

          Thanks for your quick reply. I couldn't really find the information on CopyFile()/""CopyFileEx(). Also Could you please tell me what SHBrowseForFolder is? .. I tried to search for both of these things that you suggested in the MSN VStudio Help but did't find anything . :-( Thanks ! Anjum.

          J 1 Reply Last reply
          0
          • J Joan M

            use this: ::CopyFile(csOrigen,csDesti,TRUE) where csOrigen is the source path (CString), csDesti is the destination path (CString too), and the last BOOL parameter is a flag that defines if you want the operation to fail if the file exists. Take a look at the MSDN for further information...

            A Offline
            A Offline
            a3gupta
            wrote on last edited by
            #5

            Joan, Thanks, your reply helps. Just one quick follow up question. What is the best way to get the Destination path from the user? .. Thanks! Anjum.

            J 1 Reply Last reply
            0
            • A a3gupta

              Thanks for your quick reply. I couldn't really find the information on CopyFile()/""CopyFileEx(). Also Could you please tell me what SHBrowseForFolder is? .. I tried to search for both of these things that you suggested in the MSN VStudio Help but did't find anything . :-( Thanks ! Anjum.

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

              Well, my local MSDN-copy has it after entering 'shbr'. And in the online MSDN, I just needed to enter the name of the function and found [http:// msdn.microsoft.com / library / en-us / shellcc / platform / Shell / reference / functions / shbrowseforfolder.asp](http:// msdn.microsoft.com / library / en-us / shellcc / platform / Shell / reference / functions / shbrowseforfolder.asp) Now THIS is really information at your fingertips...

              1 Reply Last reply
              0
              • A a3gupta

                Joan, Thanks, your reply helps. Just one quick follow up question. What is the best way to get the Destination path from the user? .. Thanks! Anjum.

                J Offline
                J Offline
                Joan M
                wrote on last edited by
                #7

                Take a look at this link, it's an article in codeproject regarding this. http://www.codeproject.com/treectrl/pathpicker.asp NOTE: I've never used it.

                https://www.robotecnik.com freelance robots, PLC and CNC programmer.

                1 Reply Last reply
                0
                • A a3gupta

                  Hello, I have dialog based application in VC++ 6.0. I need to copy a file to a user specified location. So I am making a button, when clicked by user, would just ask for the path that they want copy the file to. They don't need to specify the name of them file. It is a default database file. After they specify the path I need to copy the database file to that location. I don't know how exactly I should implement it. I couldn't really find any function that will make a copy of a file to a specified location. What control and functions do I need to use. Thanks for helping me with this basic problem.!! I really appreciate it. Sincerey, Anjum.

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #8

                  BOOL CopyFile( LPCTSTR lpExistingFileName, // pointer to name of an existing file LPCTSTR lpNewFileName, // pointer to filename to copy to BOOL bFailIfExists // flag for operation if file exists ); You will find more info on this in the MSDN Help File. Good luck.

                  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