I have a procedure in a data module that I use in both a Delphi ISAPI DLL and Windows Service for copying all the files in a specified folder into a new folder. The code is something like this:
if DirectoryExists(OldPath) then
begin
ForceDirectories(NewPath);
lFiles := TDirectory.GetFiles(OldPath);
for I := 0 to Length(lFiles) - 1 do
TFile.Copy(OldPath + TPath.GetFileName(lFiles[I]), NewPath + TPath.GetFileName(lFiles[I]));
end;
The code works perfectly in the ISAPI DLL, and finishes without erroring in the service, but nothing is created. I've tried outputting the result of ForceDirectories, which returns True indicating it thinks the folder was created...
The other strange thing the service is doing, is often when I start it Windows seems to not realise it has started successfully so it will start another instance, then kill the first.
Many thanks for any help!