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. to move directories to different drives

to move directories to different drives

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

    hi, how do i move files and directories with its children, in a directory, in to another directory, in another drive? the MoveFileEx function, moves directories in same drive. but different drive ...? please help me.

    Zo.Naderi-Iran

    CPalliniC Z 2 Replies Last reply
    0
    • Z zon_cpp

      hi, how do i move files and directories with its children, in a directory, in to another directory, in another drive? the MoveFileEx function, moves directories in same drive. but different drive ...? please help me.

      Zo.Naderi-Iran

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      zon_cpp wrote:

      MoveFileEx function, moves directories in same drive. but different drive ...?

      Are you sure? The following sentence in MoveFileEx documentation[^]:

      If a file is moved across volumes, MoveFileEx does not move the security descriptor with the file. The file is assigned the default security descriptor in the destination directory.

      make me think you actually can. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      Z 1 Reply Last reply
      0
      • CPalliniC CPallini

        zon_cpp wrote:

        MoveFileEx function, moves directories in same drive. but different drive ...?

        Are you sure? The following sentence in MoveFileEx documentation[^]:

        If a file is moved across volumes, MoveFileEx does not move the security descriptor with the file. The file is assigned the default security descriptor in the destination directory.

        make me think you actually can. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        Z Offline
        Z Offline
        zon_cpp
        wrote on last edited by
        #3

        i tested MoveFileEx function. it can not move directory in different drive, with LastError = 5

        Zo.Naderi-Iran

        CPalliniC 1 Reply Last reply
        0
        • Z zon_cpp

          i tested MoveFileEx function. it can not move directory in different drive, with LastError = 5

          Zo.Naderi-Iran

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          That's 'access denied' maybe your application hasn't the rights to access the source/destination folder. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          Z 1 Reply Last reply
          0
          • Z zon_cpp

            hi, how do i move files and directories with its children, in a directory, in to another directory, in another drive? the MoveFileEx function, moves directories in same drive. but different drive ...? please help me.

            Zo.Naderi-Iran

            Z Offline
            Z Offline
            zon_cpp
            wrote on last edited by
            #5

            thank you all. i found my solution: it is SHFiliOperation function.

            SHFILEOPSTRUCT SHDirOp;
            ZeroMemory(&SHDirOp, sizeof(SHFILEOPSTRUCT));
            SHDirOp.hwnd = NULL;
            SHDirOp.wFunc = FO_COPY;
            SHDirOp.pFrom = "D:\\SourceDir\0";
            SHDirOp.pTo = "C:\\DesDir\0";
            SHDirOp.fFlags = FOF_MULTIDESTFILES|FOF_NOCONFIRMMKDIR|FOF_NOCONFIRMATION;

                if (SHFileOperation(&SHDirOp) == 0)
                       AfxMessagBo("success");
            

            Zo.Naderi-Iran

            1 Reply Last reply
            0
            • CPalliniC CPallini

              That's 'access denied' maybe your application hasn't the rights to access the source/destination folder. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              Z Offline
              Z Offline
              zon_cpp
              wrote on last edited by
              #6

              no, thank you. i found my solution: it is SHFiliOperation function.

              Zo.Naderi-Iran

              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