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. Folder Copy

Folder Copy

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

    Hi All How can i copy folder?I have a folde A whic have 9 file and 4 folder.And detination folder is B.I want to copy folder A in B.Plz help me

    _ A 3 Replies Last reply
    0
    • D Davitor

      Hi All How can i copy folder?I have a folde A whic have 9 file and 4 folder.And detination folder is B.I want to copy folder A in B.Plz help me

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      I haven't tried it myself, but I'm sure SHFileOperation will do this for you.

      «_Superman_»

      D 1 Reply Last reply
      0
      • _ _Superman_

        I haven't tried it myself, but I'm sure SHFileOperation will do this for you.

        «_Superman_»

        D Offline
        D Offline
        Davitor
        wrote on last edited by
        #3

        can you give example?

        D 1 Reply Last reply
        0
        • D Davitor

          Hi All How can i copy folder?I have a folde A whic have 9 file and 4 folder.And detination folder is B.I want to copy folder A in B.Plz help me

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Check this article CShellFileOp - Wrapper for SHFileOperation[^] by Michael Dunn[^]

          «_Superman_»

          1 Reply Last reply
          0
          • D Davitor

            Hi All How can i copy folder?I have a folde A whic have 9 file and 4 folder.And detination folder is B.I want to copy folder A in B.Plz help me

            A Offline
            A Offline
            ATM CodeProject
            wrote on last edited by
            #5

            Try this code

            bool CMainFrame::CopyFun(LPCTSTR lpctszSrc_i,LPCTSTR lpctszDetn_i)
            {

            int nSrcLen = _tcslen(lpctszSrc_i);
            int nDetnLen = _tcslen(lpctszDetn_i);

            TCHAR *pszFrom = new TCHAR[nSrcLen];
            TCHAR *pszTo = new TCHAR[nDetnLen];

            _tcscpy(pszFrom, lpctszSrc_i);
            _tcscpy(pszTo, lpctszDetn_i);

            pszFrom[nSrcLen] = 0;
            pszFrom[nSrcLen+1] = 0;

            pszTo[nDetnLen] = 0;
            pszTo[nDetnLen+1] = 0;

            SHFILEOPSTRUCT stFileop;

            //stFileop.hwnd = NULL; // no status display
            if("Copy" == m_csType )
            {
            stFileop.wFunc = FO_COPY; // copy operation
            }
            else
            {
            stFileop.wFunc = FO_MOVE; // cut operation
            }

            stFileop.pFrom = pszFrom; // source file name as double null terminated string
            stFileop.pTo = pszTo; //Destination

            //stFileop.fFlags = FOF_NOCONFIRMATION|FOF_SILENT; // do not prompt the user

            stFileop.fAnyOperationsAborted = FALSE;
            stFileop.lpszProgressTitle = NULL;
            stFileop.hNameMappings = NULL;

            int ret = SHFileOperation(&stFileop);
            //delete [] pszFrom;
            //delete [] pszTo;

            return(ret == 0);

            }

            Here lpctszSrc_i & lpctszDetn_i are the src & detn full path.

            1 Reply Last reply
            0
            • D Davitor

              can you give example?

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Davitor wrote:

              can you give example?

              Since he's given you the name of the function to use, why not just search for an example? :rolleyes:

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              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