Hello,
I'm having this issue with copying files with .NET's File.Copy() method.
I have a file, that I want to copy to a couple locations, but when doing something like:
File.Copy(source, target1);
File.Copy(source, target2);
I keep getting an exception error about the file being in use.
Seeing that if I copy it to just 1 location, wait a few moments and then copy it again, it works fine, I'm assuming that the error presented to me isn't because of the Copy() method not closing the file correctly, but rather because I'm trying to use the second copy while the first one is still being processed.
My question, then, would be, how should I go about this?
I couldn't find a method for checking if a file is currently accessed.
Would it be efficient to loop the 2nd copy in a try-catch block?
Just curious as to what others have done in a similiar situation.
Thanks for the answers to come!