Microsoft KB Archive/327267

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

Article ID: 327267

Article Last Modified on 11/17/2003

-

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 &quot;xxxxxxxx.xxx&quot; 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 &quot;Symptoms&quot; 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.

Additional query words: duplicate

Keywords: kbkernbase kbprb kbpending kbfileio KB327267

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.