Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

C++ How to recursively copy files and folders with files inside ?

Janci

New Coder
Hi guys.
I want recursively copy files and folders with files inside. If folder do not exist, just create it. I just made this code:
Code:
                CStringArray strArray1;
                fnGetAllFilesNames(strArray1);

                CString slashs("\\");
                CString pathToFTU2;
                CString pathToFTU("C:\\TEMP\\");
                pathToFTU2 = pathToFTU + m_strNameOfUpdate + slashs;
                CString pathToFTUArray("");
                CString pathToSense("C:\\ID.EST Sense Copy test folder\\");
                CString pathToSenseArray("");
                CString pathToDownload("C:\\ID.EST Sense Copy test folder\\Download");
                CString pathToDownloadArray("");
                CString pathToStyleIdest("C:\\ID.EST Sense Copy test folder\\styles");
                CString pathToStyleUpdate("");
                CString pathToStyle("styles");
                CString pathToVersionHelpIdest("C:\\ID.EST Sense Copy test folder\\VersionHelp\\");
                CString pathToVersionHelpUpdate("");
                CString pathToVersionHelp("VersionHelp");
                CString pathToReportIdest("C:\\ID.EST Sense Copy test folder\\Report");
                CString pathToReportUpdate("");
                CString pathToReport("Report");
                
                CString pathToFTUVersion = pathToFTU + m_strNameOfUpdate + slashs;

            
            int i = 0;
            for (i; i < (strArray1.GetSize()); i++)
            {

            pathToFTUArray = pathToFTU + m_strNameOfUpdate + slashs + strArray2[i];
            pathToSenseArray = pathToSense + m_strNameOfUpdate + slashs + strArray2[i];
            pathToDownloadArray = pathToDownload + slashs;
            pathToStyleUpdate = pathToFTUVersion + pathToStyle;
            pathToVersionHelpUpdate = pathToFTUVersion + pathToVersionHelp + slashs;
            pathToReportUpdate = pathToFTUVersion + pathToReport;

            fnCopyAllFile(pathToStyleIdest, pathToStyleUpdate);
            fnCopyAllFile(pathToVersionHelpIdest, pathToVersionHelpUpdate);
            fnCopyAllFile(pathToSense, pathToFTUVersion);
            }
strArray2 is string array with names of files.
Thank you.
 
I have no idea what most of this code is supposed to do, or what exactly your problem is with it.
But something looks very wrong to me:

for (i; i < (strArray1.GetSize()); i++)

Should you not be using strArray2 instead of strArray1 ?
And I think GetSize() returns the number of bytes in the array, whereas you want the number of elements in the array, which is :

sizeof(strArray2) / sizeof(strArray2[0])

I hope this helps some.
 
Back
Top Bottom