コード例 #1
0
        internal static FileSystemFileStats FromPath(string path)
        {
            var fileInfo = new FileInfo(path);

            var fileStats = new FileSystemFileStats()
            {
                Name           = fileInfo.Name,
                Extension      = fileInfo.Extension,
                CreationTime   = fileInfo.CreationTime,
                LastWriteTime  = fileInfo.LastWriteTime,
                LastAccessTime = fileInfo.LastAccessTime,
                Length         = fileInfo.Length
            };

#if !SILVERLIGHT
            fileStats.CreationTimeUTC   = fileInfo.CreationTimeUtc;
            fileStats.LastWriteTimeUTC  = fileInfo.LastWriteTimeUtc;
            fileStats.LastAccessTimeUTC = fileInfo.LastAccessTimeUtc;
#endif

            return(fileStats);
        }
コード例 #2
0
        public async Task <IFileStats> GetFileStats(CancellationToken cancellationToken = new CancellationToken())
        {
            await AwaitExtensions.SwitchOffMainThreadAsync(cancellationToken);

            var localCreationTime   = _root.GetCreationTime(_path);
            var localLastWriteTime  = _root.GetLastWriteTime(_path);
            var localLastAccessTime = _root.GetLastAccessTime(_path);

            var fileStats = new FileSystemFileStats()
            {
                Name              = _name,
                Extension         = System.IO.Path.GetExtension(_name),
                CreationTime      = localCreationTime.DateTime,
                CreationTimeUTC   = localCreationTime.UtcDateTime,
                LastWriteTime     = localLastWriteTime.DateTime,
                LastWriteTimeUTC  = localLastWriteTime.UtcDateTime,
                LastAccessTime    = localLastAccessTime.DateTime,
                LastAccessTimeUTC = localLastAccessTime.UtcDateTime
            };

            return(fileStats);
        }
コード例 #3
0
        public async Task <IFileStats> GetFileStats(CancellationToken cancellationToken = new CancellationToken())
        {
            await AwaitExtensions.SwitchOffMainThreadAsync(cancellationToken);

            return(FileSystemFileStats.FromPath(Path));
        }