internal static new IFileSystemInformation Create(string originalPath, SafeFileHandle fileHandle, FileBasicInfo info, IFileService fileService)
        {
            if ((info.Attributes & FileAttributes.FILE_ATTRIBUTE_DIRECTORY) == 0) throw new ArgumentOutOfRangeException(nameof(info));

            var directoryInfo = new DirectoryInformation(fileService);
            directoryInfo.PopulateData(originalPath, fileHandle, info);
            return directoryInfo;
        }
        protected virtual void PopulateData(string originalPath, SafeFileHandle fileHandle, FileBasicInfo info)
        {
            _source = Source.FileInfo;

            string finalPath = originalPath;

            try
            {
                string originalRoot = Paths.GetRoot(originalPath);
                finalPath = FileDesktopMethods.GetFinalPathNameByHandle(fileHandle, GetFinalPathNameByHandleFlags.FILE_NAME_NORMALIZED);

                // GetFinalPathNameByHandle will use the legacy drive for the volume (e.g. \\?\C:\). We may have started with C:\ or some other
                // volume name format (\\?\Volume({GUID}), etc.) and we want to put the original volume specifier back.
                finalPath = Paths.ReplaceCasing(finalPath, originalPath);
            }
            catch
            {
                if (originalPath.IndexOf(@"pipe", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    // Getting the final path name doesn't work with the pipes device. Not sure if there is a programmatic way
                    // to know if an arbitrary file handle won't work with GetFinalPathName- potentially may be other cases.
                    throw;
                }
            }

            _source = Source.FindResult;
            Path = finalPath;
            Attributes = (System.IO.FileAttributes)info.Attributes;
            CreationTime = info.CreationTime;
            LastAccessTime = info.LastAccessTime;
            LastWriteTime = info.LastWriteTime;
            Name = Paths.GetFileOrDirectoryName(finalPath) ?? finalPath;
            Exists = true;
        }
 internal static IFileSystemInformation Create(string originalPath, SafeFileHandle fileHandle, FileBasicInfo info, IFileService fileService)
 {
     if ((info.Attributes & FileAttributes.FILE_ATTRIBUTE_DIRECTORY) != 0)
     {
         return DirectoryInformation.Create(originalPath, fileHandle, info, fileService);
     }
     else
     {
         return FileInformation.Create(originalPath, fileHandle, info, fileService);
     }
 }