Ecere SDK/eC Forums • View topic - Copy Folder/Directory Tree Contents




Ecere SDK/eC Forums

Ecere Developers Community

Copy Folder/Directory Tree Contents

Help with the Ecere cross platform system functionality: working with files, threads, timers, databases, etc.

Copy Folder/Directory Tree Contents

Postby naji » Fri Sep 23, 2011 1:27 pm

Here is a function you can use in the Ecere SDK, eC programming language to copy the contents of a folder to another folder. Thanks to Jerome for the code.

Code: Select all
void CopyFolderContents(char * indir, char * outdir)
{
   FileListing listing { indir };
 
   MakeDir(outdir);
 
   while (listing.Find())
   {
      char location[MAX_LOCATION];
      strcpy(location, outdir);
      PathCat(location, listing.name);
 
      if (listing.stats.attribs.isDirectory)
         CopyFolderContents(listing.path, location);
      else
      {
         File file = FileOpen(listing.path, read);
         if (file)
         {
            file.CopyTo(location);
            delete file;
         }
      }
   }
}

Feel free to try out this sample program which tests the function.
Attachments
copytree.zip
Copying Folder/Directory Tree Contents Sample Project Example In Ecere
(1.45 KiB) Downloaded 551 times
naji
 
Posts: 3
Joined: Tue Mar 30, 2010 8:31 pm

Return to System Library

Who is online

Users browsing this forum: No registered users and 2 guests

cron