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. Copy folders along with subfolders in C++

Copy folders along with subfolders in C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
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
    dipeka
    wrote on last edited by
    #1

    Hi, I want to copy a folder along with it's subdirectories to another location using C++.I tried using SHFileOperation but it fails saying "Cannot copy file.Filename is too long".My folder name is just 8 characters long.Is there any better way to copy folders? Please help.... Thanks, Dipeka Dipeka.A.J

    Z J 2 Replies Last reply
    0
    • D dipeka

      Hi, I want to copy a folder along with it's subdirectories to another location using C++.I tried using SHFileOperation but it fails saying "Cannot copy file.Filename is too long".My folder name is just 8 characters long.Is there any better way to copy folders? Please help.... Thanks, Dipeka Dipeka.A.J

      Z Offline
      Z Offline
      zhang800605
      wrote on last edited by
      #2

      int SHFileOperation( LPSHFILEOPSTRUCT lpFileOp );

      D 1 Reply Last reply
      0
      • Z zhang800605

        int SHFileOperation( LPSHFILEOPSTRUCT lpFileOp );

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

        Thank u zhang.I'm using SHFileoperation but it says "Cannot copy file.Filename is too long". My folder name is only 8 characters.What could be the problem? Thanks, Dipeka Dipeka.A.J

        Z S 2 Replies Last reply
        0
        • D dipeka

          Thank u zhang.I'm using SHFileoperation but it says "Cannot copy file.Filename is too long". My folder name is only 8 characters.What could be the problem? Thanks, Dipeka Dipeka.A.J

          Z Offline
          Z Offline
          zhang800605
          wrote on last edited by
          #4

          SHFILEOPSTRUCT FileOp; FileOp.hwnd=m_hWnd; //设置句柄 //设置操作方式,拷贝用FO_COPY,删除用 FO_DELETE FileOp.wFunc=FO_COPY; FileOp.pFrom="E:\\11"; //源文件路径 FileOp.pTo="E:\\22"; //目标文件路径 FileOp.fFlags=FOF_ALLOWUNDO; //允许恢复 FileOp.hNameMappings=NULL; FileOp.lpszProgressTitle="copy"; //设置标题 SHFileOperation(&FileOp); //执行外壳拷贝

          1 Reply Last reply
          0
          • D dipeka

            Hi, I want to copy a folder along with it's subdirectories to another location using C++.I tried using SHFileOperation but it fails saying "Cannot copy file.Filename is too long".My folder name is just 8 characters long.Is there any better way to copy folders? Please help.... Thanks, Dipeka Dipeka.A.J

            J Offline
            J Offline
            Jetli Jerry
            wrote on last edited by
            #5

            hi if u dont want to use SHFileOperation. U can use CFileFind & CopyFile() Jetli Constant Thing In World Is Change.

            1 Reply Last reply
            0
            • D dipeka

              Thank u zhang.I'm using SHFileoperation but it says "Cannot copy file.Filename is too long". My folder name is only 8 characters.What could be the problem? Thanks, Dipeka Dipeka.A.J

              S Offline
              S Offline
              Sheng Jiang
              wrote on last edited by
              #6

              pFrom and pTo should be double NULL terminated. http://blog.joycode.com/jiangsheng http://blog.csdn.net/jiangsheng Command what is yours Conquer what is not ---Kane

              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