Skip to content

Add clarification that FileInfo.MoveTo modifies its FullName to point to the new file #12399

@datvm

Description

@datvm

Type of issue

Missing information

Description

Currently it's not clear if after calling MoveTo, does the FileInfo still point to the old path or the new one. In this example:

var file = new FileInfo(@"D:\Temp\test.txt");
file.MoveTo(@"D:\Temp\test2.txt");

Console.WriteLine(file.FullName); // Now prints D:\Temp\test2.txt
Console.WriteLine(file.Exists); // Prints true still

It's quite a surprising behavior for me. I thought the FileInfo stayed the same.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.io.fileinfo?view=net-10.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.IO/FileInfo.xml

Document Version Independent Id

8ff2dee9-0ff5-4e0e-e58e-c2426ae7de11

Platform Id

7223a61b-29bf-4e03-57b1-2da74b5bf9a6

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions