0

In C# console app I am trying to copy images from one dir to another and then copy the original image from original location to a processed location. I have tried Thread.Sleep etc. but with no luck. Please help!

File.Copy(sourcePath, destinationPath ,true);

File.Move(sourcePath, processedPath);

All paths are like c:\dir\subdir\image1.png but different subdir locations.

I get the following error

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.IOException: The process cannot access the file because it is being used by another process.

Grant Winney
  • 65,241
  • 13
  • 115
  • 165
chugh97
  • 9,602
  • 25
  • 89
  • 136

0 Answers0