[corlib] Fix FileInfo.ToString after MoveTo
authorMarcos Henrich <marcos.henrich@xamarin.com>
Wed, 16 Mar 2016 10:07:06 +0000 (10:07 +0000)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Wed, 16 Mar 2016 10:07:06 +0000 (10:07 +0000)
Fixes #38796

mcs/class/corlib/System.IO/FileInfo.cs

index 1e53bade58fbf5653b11b0d124bbbe31e7ead55b..69e1f32ffdd74bcf0f4b446b145468b9301769b1 100644 (file)
@@ -48,6 +48,7 @@ namespace System.IO {
        public sealed class FileInfo : FileSystemInfo
        {
                private bool exists;
+               private string displayPath;
 
                public FileInfo (string fileName)
                {
@@ -59,11 +60,14 @@ namespace System.IO {
 
                        OriginalPath = fileName;
                        FullPath = Path.GetFullPath (fileName);
+                       
+                       displayPath = OriginalPath;
                }
 
                private FileInfo (SerializationInfo info, StreamingContext context)
                        : base (info, context)
                {
+                       displayPath = OriginalPath;
                }
 
                internal override void InternalRefresh ()
@@ -241,6 +245,8 @@ namespace System.IO {
 
                        File.Move (FullPath, destFullPath);
                        this.FullPath = destFullPath;
+
+                       displayPath = destFileName;
                }
 
                public FileInfo CopyTo (string destFileName)
@@ -267,7 +273,7 @@ namespace System.IO {
 
                public override string ToString ()
                {
-                       return OriginalPath;
+                       return displayPath;
                }
 
 #if !MOBILE