Programmatically Copy Files in C++

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

  1. slsh==

    slsh== New Member

    Joined:
    Jun 28, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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.

    slsh==
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice