Pelles C forum

C language => Beginner questions => Topic started by: lairdre on May 25, 2007, 08:16:25 PM

Title: File copy
Post by: lairdre on May 25, 2007, 08:16:25 PM
I'm new to Pelles C and this forum. I was looking through some of the non-standard c functions.  Is there one or does one exist in the forum to copy files? I've seen rename, delete and a few other very helpfull ones.

Thanks,

Ron
Title: Re: File copy
Post by: jcarr on May 26, 2007, 03:41:50 AM
You can use API to do this quick routine:
int copyf(char copyfrom[], char copyto[])
{
        SHFILEOPSTRUCT fileop;
        fileop.hwnd = NULL;
        fileop.wFunc = FO_COPY;
        fileop.pFrom = copyfrom;
        fileop.pTo = copyto;
        fileop.fFlags = FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR;
        if( (SHFileOperation(&fileop)) != 0)
        {
            return 0;
        }
        return 1;
}

You should also need to include <windows.h>... i think  :P

good luck!

jcarr
Title: Re: File copy
Post by: skirby on May 30, 2007, 01:27:12 PM
You can simply use Windows API CopyFile function.

See MSDN for more informations.