ms10
ms10

Reputation: 91

Could not find destination file during file copy

We've seen this issue described elsewhere when it relates to the source file, but not the destination file.

We're trying to copy a 70MB file from a local path on the source server to a share on the destination server. The entire process is iterating over many files on the main thread and other files have successfully copied before we see the issue. However, we occasionally see this error:

Could not find file 'DestinationFileFullPath'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)

I need to emphasize this point: the error refers to the destination file name, not the source. And we're certain that we haven't mixed up the variables. This is the code:

ConsoleLog(String.Format("Copying file from {0} to {1}", source, dest));
File.Copy(source, dest);

Does anyone have any idea what's causing this?

Upvotes: 0

Views: 1762

Answers (2)

Sledge
Sledge

Reputation: 1

You can also see this message if the destination file name (excluding any extension) is a reserved DOS name: CON, PRN, AUX, NUL, COM1-9, LPT1-9.

Upvotes: 0

ricardomsouto
ricardomsouto

Reputation: 51

A possibility for anyone who might end up on this thread:

You will get this error in both File.Move and File.Copy if the 'source' and 'destination' arguments are the same.

Upvotes: 1

Related Questions