Ecere SDK/eC Forums
https://ec-lang.org/community/
Print view

Copy Folder/Directory Tree Contents
https://ec-lang.org/community/viewtopic.php?f=9&t=198
Page 1 of 1
Author:  naji [ Fri Sep 23, 2011 1:27 pm ]
Post subject:  Copy Folder/Directory Tree Contents

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.
All times are UTC-05:00 Page 1 of 1