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.
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.
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 .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With