I use SHFileOperation Function to copy all the files and sub directories
from a shared Folder across a network, to a local directory.
It works fine, except for the following problem:
- Cannot copy <FileName>. Process cannot Access the file because
another process has locked a portion of the file.
As soon as the above error occurs the entire copy procedure is canceled. How
can I just skip over the locked file and continue to copy the other files in
the directory. Does it mean that I need to check every file, to see if it is
in use, and then call the SHFileOperation to copy the file if not in use?
Can anyone help me to solve this problem?
***Your Function Starts***
// some code here
try
{
SHFileOperation
}
catch (Exception &E)
{
// error handling code here (if required), otherwise leave empty
}
// remaining code
***Your Function Ends***
Hope this helps
Regards,
Muhammad Momin Rashid.
"Magnus van Aardt" <mva...@srcc.co.za> wrote in message
news:3ef6...@newsgroups.borland.com...
Procedure MyFileCopyOperation;
Begin
{some code here}
try
SHFileOperation( ... );
except
On Exception do
{ Exception Handling code here (if required) };
end;
End;
{ some code here}
End;
Search String I used:
http://www.google.com/search?num=100&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&q=
exception+handling+delphi
Regards,
Muhammad Momin Rashid
"Muhammad Momin Rashid" <mo...@hotmail.com> wrote in message
TRy to add the FOF_NOERRORUI flag to the flags set. If that does not solve the problem
you may indeed have to copy file by file. Or use the good old XCOPY program via
ShellExecute, it has a command line option to continue after errors.
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
This is somewhat pointless since API functions, as a rule, do not raise
exceptions, they return result codes.
Look into implementing a SHFileOperation copy callback handler.
David-