Welcome, Guest
Username: Password: Remember me
CodeTyphon MS Windows (Win7, Win8.x, Win10 and Win11) OS Development, discussions and problems
  • Page:
  • 1

TOPIC:

CopyFile Question 8 years 7 months ago #9484

  • Dennis Jones
  • Dennis Jones's Avatar Topic Author
  • Visitor
  • Visitor
I have been fighting this for 2 days. I get failure message for the following code, even though source and destination file names are correct:

procedure TMainForm.FormDropFiles(Sender: TObject; //===
const FileNames: array of String);
var
FileName, DIPPRID, DestFile : String;
begin
for FileName in FileNames do begin
DIPPRID := ExtractFileName(FileName);
DIPPRID := Copy(ExtractFileName(FileName), 1, Pos(' ', DIPPRID));
CreateDir (Settings.ProgramDirectory + 'Projects\' + DIPPRID);
DestFile := Settings.ProgramDirectory + 'Projects\' + DIPPRID + '\' ; //+ ExtractFileName(FileName);
if CopyFile(FileName, DestFile, [], False) then
ShowMessage('Success')
else
ShowMessage('Failure');

// UnZip.BaseDirectory := Settings.ProgramDirectory + 'Projects\' + DIPPRID;
// UnZip.FileName := FileName;
// UnZip.ExtractFiles('*');
end;
end;

Please Log in or Create an account to join the conversation.

CopyFile Question 8 years 7 months ago #9485

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Sir
my suggestion is
procedure TMainForm.FormDropFiles(Sender: TObject; //===
const FileNames: array of String);
var
FileName, DIPPRID, DestFile : String;
i:integer; 
begin

For i:=Low(FileNames) to High(FileNames) do
begin
 FileName := FileNames[i];

 DIPPRID := ExtractFileName(FileName);
 DIPPRID := Copy(ExtractFileName(FileName), 1, Pos(' ', DIPPRID));
 CreateDir (Settings.ProgramDirectory + 'Projects\' + DIPPRID);
 DestFile := Settings.ProgramDirectory + 'Projects\' + DIPPRID + '\' ; //+ ExtractFileName(FileName);
 if CopyFile(FileName, DestFile, [], False) then
 ShowMessage('Success')
 else
 ShowMessage('Failure');

// UnZip.BaseDirectory := Settings.ProgramDirectory + 'Projects\' + DIPPRID;
// UnZip.FileName := FileName;
// UnZip.ExtractFiles('*');
end;
end; 
:

PS: Good morning with my fist coffee.. :)
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

CopyFile Question 8 years 7 months ago #9486

  • Dennis Jones
  • Dennis Jones's Avatar Topic Author
  • Visitor
  • Visitor
Still Failure. Also changed to DestFile := Settings.ProgramDirectory + 'Projects\' + DIPPRID + '\' + ExtractFileName(FileName);

Please Log in or Create an account to join the conversation.

  • Page:
  • 1