Subj : Re: directory trees To : borland.public.cpp.borlandcpp From : "Dennis Jones" Date : Mon Apr 12 2004 08:40 pm "mike" wrote in message news:407ae2f1$1@newsgroups.borland.com... > hi, > > i was writing my own installer program for my app, but i ran into a > roadblock.i need to copy over directory trees which contains both files and > directories. i am using pure win32 (no OWL or MFC) and there is no > CopyDirectory (). there is a CopyFile (), but the tree that i want to copy > has a lot of files and i don't want to do it that way. plus when i add a > file to the tree i wil have to remember to update the intstaller. i was > wondering if there is a good way to do this? the only other way i could > think of was to spawn a new process and call xcopy to do the directory copy. > any ideas? You have already received a couple of good suggestions, but if you still want a function to copy whole directories, I have a set of functions that I wrote a long time ago to do just that: bool CopyTree( char *SourceDirectory, char *TargetDirectory ); bool DeleteTree( char *SourceDirectory, bool bEraseReadOnlyFiles = false ); bool MoveTree( char *SourceDirectory, char *TargetDirectory, bool bMoveReadOnlyFiles = false ); Let me know if you are interested in having these, and I will gladly post them to the attachments newsgroup. They are written entirely with the Win32 API (no VCL) because they were written for VC++. I also found the code below with a google search. It's Delphi, but it would be a fairly easy port to C: function CopyTree(dir, dest: string): Boolean; var sfos: TSHFileOpStruct; begin FillChar(sfos, SizeOf(sfos), 0); dir := dir + '\*.*'#0; dest := dest + '\*.*'#0; with sfos do begin wnd := 0; wfunc := FO_COPY; pFrom := PChar(dir); pTo := PChar(dest); fFlags:= FOF_ALLOWUNDO or FOF_RENAMEONCOLLISION or FOF_SIMPLEPROGRESS; fAnyOperationsAborted := false; hNameMappings := nil; lpszProgressTitle := nil end; Result := SHFileOperation(sfos) = 0 end; - Dennis .