I want to copy files from one folder to another using the CopyFile function. Source file paths are stored in a ClientDataSet called "itemsDB". Code:
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 "invalid file name directory name or volume label syntax". I returned all the file paths to the DataSet, they are 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 fine, but when I get its from clientdataset, it fails.
Thank you in advance
source share