Пример #1
0
        public override Task <StorageFileProperties> GetPropertiesAsync(CancellationToken cancellationToken = default)
        {
            return(Task.Run(() =>
            {
                _fileInfo.Refresh();
                EnsureExists(cancellationToken);

                // Attempting to get the real file name can fail, e.g. the file might have been deleted in between.
                // In such a case, simply return the last fetched name. It will happen rarely and is good enough
                // for such cases.
                cancellationToken.ThrowIfCancellationRequested();
                var realFileName = FsHelper.GetRealFileName(_fullPath.ToString()) ?? _fileInfo.Name;
                var lastWriteTime = File.GetLastWriteTimeUtc(_fullPath.ToString());

                return new StorageFileProperties(
                    realFileName,
                    IOPath.GetFileNameWithoutExtension(realFileName),
                    PhysicalPathHelper.GetExtensionWithoutTrailingExtensionSeparator(realFileName)?.ToNullIfEmpty(),
                    _fileInfo.CreationTimeUtc,
                    lastWriteTime,
                    (ulong)_fileInfo.Length
                    );
            }, cancellationToken));
        }