Skip to content

In TStartupCopy, provide a way to copy all files in a folder #312

@MyBuzzTechnologies

Description

@MyBuzzTechnologies

The current TStartupCopy class works brilliantly. However, if I want to copy (replace) all files in a specific folder or sub-folder, I need to first retrieve a list of their names and pass as the first parameter into CopyDocuments() which does the same.

To save this step and make the use easier, if the AFilenames parameter is passed as an empty array, could it copy all files?

e.g.: (Not the most efficient implementation. Just an example)

for LSourceFileName in TDirectory.GetFiles(LSourcePath, '*.*', TSearchOption.soTopDirectoryOnly) do
begin
      LIndex := IndexStr(TPath.GetFileName(LSourceFileName), AFileNames);
      if (Length(FileNames) = 0) or (LIndex > -1) then
        TFile.Copy(LSourceFileName, TPath.Combine(LDestPath, AFileNames[LIndex]), True);
end;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions