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. SHFileOperation

SHFileOperation

Scheduled Pinned Locked Moved C / C++ / MFC
help
9 Posts 5 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.
  • M Offline
    M Offline
    MsmVc
    wrote on last edited by
    #1

    Hi All I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.

    C:\\Test(Source Folder)
    C:\\Test2(Deswtination folder)

    This is working fine. But when i copy file like this then it's not working.

    C:\\log.txt(Source)
    C:\\ (Destination)

    Plz help me:rose:

    C F 2 Replies Last reply
    0
    • M MsmVc

      Hi All I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.

      C:\\Test(Source Folder)
      C:\\Test2(Deswtination folder)

      This is working fine. But when i copy file like this then it's not working.

      C:\\log.txt(Source)
      C:\\ (Destination)

      Plz help me:rose:

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

      MsmVc wrote:

      C:\\log.txt(Source)C:\\ (Destination)

      And whats should it do (i.e. what is the expected 'working' behaviour)? :)

      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]

      1 Reply Last reply
      0
      • M MsmVc

        Hi All I am useing SHFileOperation for copy folder.It's working nice for folder.Can i use SHFileOperation for file also.I mean when i copy folder like this.

        C:\\Test(Source Folder)
        C:\\Test2(Deswtination folder)

        This is working fine. But when i copy file like this then it's not working.

        C:\\log.txt(Source)
        C:\\ (Destination)

        Plz help me:rose:

        F Offline
        F Offline
        fantasy1215
        wrote on last edited by
        #3

        void CTestgarbageDlg::OnButton1()
        {
        SHFILEOPSTRUCT shop;
        shop.hwnd = this->GetSafeHwnd();
        shop.wFunc = FO_COPY;
        shop.pFrom = _T("c:\\AUTOEXEC.BAT\0");
        shop.pTo = _T("d:\0");
        shop.fFlags = FOF_FILESONLY;

        int iRet = -1;
        iRet = SHFileOperation(&shop);
        if (iRet == 0)
        {
        	//sucess
        	AfxMessageBox(\_T("sucess"));
        }
        else
        {
        	AfxMessageBox(\_T("fail"));
        }
        

        }

        I've tried the code above, it works fine. Hope it helps you.

        C 1 Reply Last reply
        0
        • F fantasy1215

          void CTestgarbageDlg::OnButton1()
          {
          SHFILEOPSTRUCT shop;
          shop.hwnd = this->GetSafeHwnd();
          shop.wFunc = FO_COPY;
          shop.pFrom = _T("c:\\AUTOEXEC.BAT\0");
          shop.pTo = _T("d:\0");
          shop.fFlags = FOF_FILESONLY;

          int iRet = -1;
          iRet = SHFileOperation(&shop);
          if (iRet == 0)
          {
          	//sucess
          	AfxMessageBox(\_T("sucess"));
          }
          else
          {
          	AfxMessageBox(\_T("fail"));
          }
          

          }

          I've tried the code above, it works fine. Hope it helps you.

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

          fantasy1215 wrote:

          shop.pFrom = _T("c:\\AUTOEXEC.BAT\0"); shop.pTo = _T("d:\0");

          Why do you double terminate the strings? Nevermind, it was my ignorance. :)

          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]

          modified on Monday, October 6, 2008 4:38 AM

          S 1 Reply Last reply
          0
          • C CPallini

            fantasy1215 wrote:

            shop.pFrom = _T("c:\\AUTOEXEC.BAT\0"); shop.pTo = _T("d:\0");

            Why do you double terminate the strings? Nevermind, it was my ignorance. :)

            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]

            modified on Monday, October 6, 2008 4:38 AM

            S Offline
            S Offline
            SandipG
            wrote on last edited by
            #5

            Documentation says to end it with two null chars. Rajesh has verified it it works with single null termination also.

            Regards, Sandip.

            R C 2 Replies Last reply
            0
            • S SandipG

              Documentation says to end it with two null chars. Rajesh has verified it it works with single null termination also.

              Regards, Sandip.

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              SandipG :) wrote:

              Rajesh has verified it it works with single null termination also.

              Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted. But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated. :)

              Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

              C S 2 Replies Last reply
              0
              • S SandipG

                Documentation says to end it with two null chars. Rajesh has verified it it works with single null termination also.

                Regards, Sandip.

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                SandipG wrote:

                Documentation says to end it with two null chars.

                Thank you.

                SandipG wrote:

                Rajesh has verified it it works with single null termination also.

                I know he likes the pragmatic approach. :)

                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]

                1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  SandipG :) wrote:

                  Rajesh has verified it it works with single null termination also.

                  Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted. But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated. :)

                  Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  You're definitely a nit-picker! :-D

                  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]

                  1 Reply Last reply
                  0
                  • R Rajesh R Subramanian

                    SandipG :) wrote:

                    Rajesh has verified it it works with single null termination also.

                    Actually, I just said that it worked in *that particular* case, as it might work with certain cases, which cannot be predicted. But that isn't the best thing to do. Because if there is a buffer overrun, then that could be disastrous. And - Those strings must be double null-terminated. :)

                    Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche .·´¯`·->Rajesh<-·´¯`·. [Microsoft MVP - Visual C++]

                    S Offline
                    S Offline
                    SandipG
                    wrote on last edited by
                    #9

                    Yes, I agree.. :)

                    Regards, Sandip.

                    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