private FileSystemInfo GetNewPathForFileAfterMoving(FileSystemInfo file, DirectoryInfo sourceDirectory, DirectoryInfo destinationDirectory) { if (!file.IsInDirectory(sourceDirectory)) return file; var relativePath = file.GetRelativePath(sourceDirectory.FullName); var newPath = Path.Combine(destinationDirectory.FullName, relativePath); if (file is DirectoryInfo) return new DirectoryInfo(newPath); return new FileInfo(newPath); }