I want to copy files from one folder to another using CopyFile function. The source files paths are stored in a ClientDataSet called "itemsDB". The code is :
Var Source, Dest : String;
Begin
itemsDB.First;
While Not itemsDB.EOF do
Begin
Source := itemsDB.FieldValues['FileN'];
Dest := 'C:\NewDir\'+ExtractFileName(Source);
if Not CopyFile(PChar(Source), PChar(Dest), False) then
Showmessage(SysErrorMessage(getlasterror()));
itemsDB.Next;
end;
end
When I execute the code, I get the error message "the filename directory name or volume label syntax is incorrect". I verfied all the files paths in the DataSet, they're correct. In my example, my clientdataset contains two JPG images "c:\test1.jpg" and "c:\test2.jpg" When I tried source := 'c:\test1.jpg', it works perfectly, but when I get it from the clientdataset, it fails.
Thanks in advance