PRB: The FileInfo.CopyTo Method May Raise a System.IO.IOException Error If the Same File Exists (327267)



The information in this article applies to:

  • Microsoft .NET Framework Class Libraries 1.0
  • Microsoft .NET Framework Class Libraries 1.1

This article was previously published under Q327267

SYMPTOMS

If you try to create or copy a file whose name is in the short (8.3) format (8 characters, a dot, and then a 3-character extension), the attempt may not succeed and you may receive an error that indicates that the file already exists.

If the System.IO.FileInfo.CopyTo method is used to copy the file, you receive the following error message:
System.IO.IOException: The file "xxxxxxxx.xxx" already exists.

CAUSE

For every long file name, the system automatically generates a short (8.3) file name so that 16-bit and DOS applications can also access the file. The error mentioned in "Symptoms" occurs when one of the auto-generated short names matches the name of the file that is being created or copied. To verify this from a command prompt, change to the appropriate directory, and then run the dir /X command.

RESOLUTION

To work around this problem, select a different name for the file that is being created or copied.

STATUS

This behavior is by design.

Modification Type:MinorLast Reviewed:11/17/2003
Keywords:kbFileIO kbKernBase kbpending kbprb KB327267 kbAudDeveloper