Posted by Jenny on January In Reply to: Make a CD to place directories on the G: disk posted by john To create a directory in one step, creating all in-between directories, use the Delphi function ForceDirectories. Because Delphi does not have routines for copying files nor directories, use the Windows API CopyFile function to copy one file: CopyFile(PointerToSourceName, PointerToDestinationName, DoNotOverwrite) If the parameter DoNotOverwrite is True, an existing file will not be overwritten. So, use False if you want to copy in any case. Example for copying some files from drive F: to drive C: SourceDir := 'f:\'; DestDir := 'c:\program files\photo'; ForceDirectories(DestDir); FileName := 'a.dll'; CopyFile(PChar(SourceDir+'\'+FileName), PChar(DestDir+'\'+FileName), False); FileName := 'b.dll'; CopyFile(PChar(SourceDir+'\'+FileName), PChar(DestDir+'\'+FileName), False); SourceDir := 'f:\examples'; DestDir := 'c:\program files\photo\examples'; ForceDirectories(DestDir); FileName := 'a.jpg'; CopyFile(PChar(SourceDir+'\'+FileName), PChar(DestDir+'\'+FileName), False); FileName := 'b.jpg'; CopyFile(PChar(SourceDir+'\'+FileName), PChar(DestDir+'\'+FileName), False); If not to many files have to be copied, you can use the above code to copy each file. Related Articles and Replies
|