/// <summary> /// Returns a <see cref="FileSystemMetadata"/> object for the specified file or directory path. /// </summary> /// <param name="path">A path to a file or directory.</param> /// <returns>A <see cref="FileSystemMetadata"/> object.</returns> /// <remarks>If the specified path points to a directory, the returned <see cref="FileSystemMetadata"/> object's /// <see cref="FileSystemMetadata.IsDirectory"/> property will be set to true and all other properties will reflect the properties of the directory.</remarks> public FileSystemMetadata GetFileSystemInfo(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } if (_sharpCifsFileSystem.IsEnabledForPath(path)) { return(_sharpCifsFileSystem.GetFileSystemInfo(path)); } // Take a guess to try and avoid two file system hits, but we'll double-check by calling Exists if (Path.HasExtension(path)) { var fileInfo = new FileInfo(path); if (fileInfo.Exists) { return(GetFileSystemMetadata(fileInfo)); } return(GetFileSystemMetadata(new DirectoryInfo(path))); } else { var fileInfo = new DirectoryInfo(path); if (fileInfo.Exists) { return(GetFileSystemMetadata(fileInfo)); } return(GetFileSystemMetadata(new FileInfo(path))); } }