Copy Folder/Directory Tree Contents

Help with the Ecere cross platform system functionality: working with files, threads, timers, databases, etc.
Post Reply
naji
Posts: 3
Joined: Tue Mar 30, 2010 8:31 pm

Copy Folder/Directory Tree Contents

Post by naji »

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.44 KiB) Downloaded 1633 times
Post Reply