+
+#if !NET_2_1
+ public FileSecurity GetAccessControl ()
+ {
+ return File.GetAccessControl (FullPath);
+ }
+
+ public FileSecurity GetAccessControl (AccessControlSections includeSections)
+ {
+ return File.GetAccessControl (FullPath, includeSections);
+ }
+
+ [ComVisible (false)]
+ public FileInfo Replace (string destinationFileName,
+ string destinationBackupFileName)
+ {
+ string destinationFullPath = null;
+ if (!Exists)
+ throw new FileNotFoundException ();
+ if (destinationFileName == null)
+ throw new ArgumentNullException ("destinationFileName");
+ if (destinationFileName.Length == 0)
+ throw new ArgumentException ("An empty file name is not valid.", "destinationFileName");
+
+ destinationFullPath = Path.GetFullPath (destinationFileName);
+
+ if (!File.Exists (destinationFullPath))
+ throw new FileNotFoundException ();
+
+ FileAttributes attrs = File.GetAttributes (destinationFullPath);
+
+ if ( (attrs & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
+ throw new UnauthorizedAccessException ();
+
+ if (destinationBackupFileName != null) {
+ if (destinationBackupFileName.Length == 0)
+ throw new ArgumentException ("An empty file name is not valid.", "destinationBackupFileName");
+ File.Copy (destinationFullPath, Path.GetFullPath (destinationBackupFileName), true);
+ }
+ File.Copy (FullPath, destinationFullPath,true);
+ File.Delete (FullPath);
+ return new FileInfo (destinationFullPath);
+ }
+
+ [ComVisible (false)]
+ [MonoLimitation ("We ignore the ignoreMetadataErrors parameter")]
+ public FileInfo Replace (string destinationFileName,
+ string destinationBackupFileName,
+ bool ignoreMetadataErrors)
+ {
+ return Replace (destinationFileName, destinationBackupFileName);
+ }
+
+ public void SetAccessControl (FileSecurity fileSecurity)
+ {
+ File.SetAccessControl (FullPath, fileSecurity);
+ }
+#endif