Пример #1
0
        private async Task <Dictionary <string, string> > GetProperties(StorageFile temporaryFile, CancellationToken cancellationToken)
        {
            StorageItemContentProperties properties = temporaryFile.Properties;
            MusicProperties musicProperties         = await properties.GetMusicPropertiesAsync();

            VideoProperties videoProperties = await properties.GetVideoPropertiesAsync();

            BasicProperties basicProperties = await temporaryFile.GetBasicPropertiesAsync();

            CancelTask(cancellationToken);

            Dictionary <string, string> tempDictionary = new Dictionary <string, string>();

            tempDictionary["Display Name"]        = temporaryFile.DisplayName;
            tempDictionary["File Type"]           = temporaryFile.FileType;
            tempDictionary["Current Folder Path"] = temporaryFile.FolderRelativeId;
            tempDictionary["Size"]           = string.Format("{0:0.00}", (Convert.ToDouble(basicProperties.Size) / 1048576d)) + " Mb";
            tempDictionary["Creation Date"]  = temporaryFile.DateCreated.ToString();
            tempDictionary["Modified Date"]  = basicProperties.DateModified.ToString();
            tempDictionary["Audio Bit Rate"] = musicProperties.Bitrate + " bps";
            tempDictionary["Length"]         = videoProperties.Duration.ToString("hh\\:mm\\:ss");
            tempDictionary["Frame Width"]    = videoProperties.Width + "";
            tempDictionary["Frame Height"]   = videoProperties.Height + "";
            tempDictionary["Orientation"]    = videoProperties.Orientation + "";
            tempDictionary["Total Bit Rate"] = videoProperties.Bitrate + " bps";

            CancelTask(cancellationToken);

            return(tempDictionary);
        }
Пример #2
0
        // 通过 StorageFolder.Properties 的 GetImagePropertiesAsync(), GetVideoPropertiesAsync(), GetMusicPropertiesAsync(), GetDocumentPropertiesAsync() 方法获取文件的属性
        private async Task ShowProperties4(StorageFile storageFile)
        {
            StorageItemContentProperties storageItemContentProperties = storageFile.Properties;
            ImageProperties imageProperties = await storageItemContentProperties.GetImagePropertiesAsync();          // 图片属性

            VideoProperties videoProperties = await storageItemContentProperties.GetVideoPropertiesAsync();          // 视频属性

            MusicProperties musicProperties = await storageItemContentProperties.GetMusicPropertiesAsync();          // 音频属性

            DocumentProperties documentProperties = await storageItemContentProperties.GetDocumentPropertiesAsync(); // 文档属性

            lblMsg.Text += "image width:" + imageProperties.Width;
            lblMsg.Text += Environment.NewLine;
            lblMsg.Text += "image height:" + imageProperties.Height;
            lblMsg.Text += Environment.NewLine;
        }