Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File Operations - Copy and Move - Delphi

Tags:

file-io

delphi

I need to do a two fold operation in Delphi.

First is reading a directory and copy all of the files into a backup folder. If any of the files are currently in use as being written to and/or open, then bypass that file.

Second is to move the file to another directory. Again, if any of the files are currently in use as being written to and/or open, then bypass that file.

I have used file copy and move before, but I am unsure as to how to detect whether a file is being written to and/or open.

Thanks.

like image 541
t j Avatar asked Aug 31 '13 18:08

t j


People also ask

Which operation is used to move a folder from one location to another?

You can use the drag and drop operation to copy and move files from the Folder View, path pane, or file pane to the following destinations: Any icon onto any folder icon in pathpane, file pane, or folder view.

How do I copy and move a file in Ubuntu?

Select the file you want to copy by clicking on it once. Right-click and pick Copy, or press Ctrl + C . Navigate to another folder, where you want to put the copy of the file. Click the menu button and pick Paste to finish copying the file, or press Ctrl + V .


1 Answers

If you use Windows.pas' CopyFile(PChar(sFrom),PChar(sTo),false) it will return false when the copy fails, and GetLastError will return an error-code explaining why.

like image 130
Stijn Sanders Avatar answered Nov 15 '22 07:11

Stijn Sanders