using System.Runtime.Serialization;
using System.Security;
-#if !NET_2_1
+#if !MOBILE
using System.Security.AccessControl;
#endif
public sealed class FileInfo : FileSystemInfo
{
private bool exists;
+ private string displayPath;
-#if MOONLIGHT
- internal FileInfo ()
- {
- }
-#endif
public FileInfo (string fileName)
{
if (fileName == null)
OriginalPath = fileName;
FullPath = Path.GetFullPath (fileName);
+
+ displayPath = OriginalPath;
}
private FileInfo (SerializationInfo info, StreamingContext context)
: base (info, context)
{
+ displayPath = OriginalPath;
}
internal override void InternalRefresh ()
}
}
-#if !NET_2_1
public bool IsReadOnly {
get {
if (!Exists)
// handling this exception to work properly.
throw new NotSupportedException (Locale.GetText ("File encryption isn't supported on any file system."));
}
-#endif
public long Length {
get {
{
if (destFileName == null)
throw new ArgumentNullException ("destFileName");
- if (destFileName == Name || destFileName == FullName)
+ if (destFileName.Length == 0)
+ throw new ArgumentException ("An empty file name is not valid.", "destFileName");
+
+ var destFullPath = Path.GetFullPath (destFileName);
+ if (destFullPath == FullPath)
return;
if (!File.Exists (FullPath))
throw new FileNotFoundException ();
- File.Move (FullPath, destFileName);
- this.FullPath = Path.GetFullPath (destFileName);
+ File.Move (FullPath, destFullPath);
+ this.FullPath = destFullPath;
+
+ displayPath = destFileName;
}
public FileInfo CopyTo (string destFileName)
public override string ToString ()
{
-#if NET_2_1
- // for Moonlight we *never* return paths, since ToString is not [SecurityCritical] we simply return the Name
- return Name;
-#else
- return OriginalPath;
-#endif
+ return displayPath;
}
-#if !NET_2_1
+#if !MOBILE
public FileSecurity GetAccessControl ()
{
return File.GetAccessControl (FullPath);