[Mono-bugs] [Bug 510230] New: Using File.Copy with src and dest being the same, truncates the file

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jun 4 20:52:44 EDT 2009


           Summary: Using File.Copy with src and dest being the same,
                    truncates the file
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jankit at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Steps to reproduce:

Create a non-empty file foo.txt in the current directory,
compile and run this.

using System.IO;

public class test {
    public static void Main ()
        File.Copy ("foo.txt", "foo.txt", true);

Result is that the file gets truncated.

net gives this:

Unhandled Exception: System.IO.IOException: The process cannot access the file
f:\foo.txt' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName,
olean overwrite)
   at test.Main()

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list