Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Windows
please, I need native code for copying a given sytem of directories,subdirectories, subsubdirectories etc and their file content.
Posted 10-Sep-12 19:20pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Did you use Google to find a solution?
Here is a nice links that will help you:
http://www.cplusplus.happycodings.com/Algorithms/code38.html[^]
And here is some sample code:
    #include <windows.h>
#include <iostream>
using namespace std;
int main()
{
    SHFILEOPSTRUCT sf;
    memset(&sf,0,sizeof(sf));
    sf.hwnd = 0;
    sf.wFunc = FO_COPY;
    sf.pFrom = "d:\\masm32\\*.*";
    sf.pTo = "d:\\masm33";
    sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI;
    int n = SHFileOperation(&sf);
    if( n == 0)
    {
      cout << "Success\n";
    }
    else
    {
      cout << "Failed\n";
    }
}
  Permalink  
Comments
Mehdi Gholam at 11-Sep-12 0:29am
   
5'ed, just posted the same.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Use ShellExecute : http://msdn.microsoft.com/en-us/library/bb762153%28VS.85%29.aspx[^]
 
With a command like :
xcopy.exe /s /q /y srcdir destdir
  Permalink  
Comments
JF2015 at 11-Sep-12 0:31am
   
This solution is simple but perfect. 5+
Mehdi Gholam at 11-Sep-12 0:33am
   
Cheers :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100