public void MoveTo(string destDirName) { if (Common.IsRunningOnMono()) { SysDirectoryInfo.MoveTo(destDirName); return; } if (destDirName == null) { throw new ArgumentNullException("destDirName"); } #if NET_2_0 if (string.IsNullOrEmpty(destDirName)) #else if (string.IsNullOrWhiteSpace(destDirName)) #endif { throw new ArgumentException("Empty filename", "destDirName"); } string fullDestDirName = Path.GetFullPath(destDirName); if (!fullDestDirName.EndsWith(Path.DirectorySeparatorChar)) { fullDestDirName = fullDestDirName + Path.DirectorySeparatorChar; } String fullSourcePath; if (FullPath.EndsWith(Path.DirectorySeparatorChar)) { fullSourcePath = FullPath; } else { fullSourcePath = FullPath + Path.DirectorySeparatorChar; } if (String.Compare(fullSourcePath, fullDestDirName, StringComparison.OrdinalIgnoreCase) == 0) { throw new IOException("source and destination directories must be different"); } String sourceRoot = Path.GetPathRoot(fullSourcePath); String destinationRoot = Path.GetPathRoot(fullDestDirName); if (String.Compare(sourceRoot, destinationRoot, StringComparison.OrdinalIgnoreCase) != 0) { throw new IOException("Source and destination directories must have same root"); } File.Move(fullSourcePath, fullDestDirName); }