1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Programmatically Copy Files in C++

Discussion in 'C++' started by slsh==, Jun 28, 2010.

  1. slsh==

    slsh== New Member

    Jun 28, 2010
    Likes Received:
    Trophy Points:
    I am in progress of making a program in C++, based on a program I made earlier, in a batch file. Everything is going smoothly so far, except for one thing; copying.

    In my original program, I used the xcopy command with /s and /y.
    Something like this: (This isn't exactly how it was written; I had prompts for setting the variables.)

    set extention="sav"
    set copyDirectory="%homedrive%%homepath%files\"
    set targetDirectory="G:\things"
    xcopy %targetDirectory\*.%extention% %copydirectory% /s /y

    Without all those variables, it'd look something like this:

    xcopy G:\things\*.sav C:\Users\User\Desktop\files\ /s /y

    What I want to do is copy all files of one extention in all subfolders while keeping the folder structure, and not copying empty folders.

    I am fairly new to C++, and I started about a month ago. I made my batch program about three years ago.

    If this really matters, I am using Windows 7 Ultimate x86, and was using Windows XP Professional when I made my batch program. I use Dev-C++ to link and compile my C++ programs, and have installed Allegro and SDL libraries.


Share This Page