我如何在C#中显示Wav文件的属性? [英] How I Show Properties Of Wav File In C#?

查看:60
本文介绍了我如何在C#中显示Wav文件的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想快速回答因为我有一个项目。

i want answer very quickly because i have a project ,please.

推荐答案

使用Microsoft.WindowsAPICodePack SDK。



Use the Microsoft.WindowsAPICodePack SDK.

using System;
using System.Windows.Forms;
using FileGeo.UIComponents.GridView;
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;

namespace FileGeo
{
    public partial class FileMetadata : Form
    {
        public ShellObject FileShellObject { get; private set; }

        public FileMetadata()
        {
            InitializeComponent();
            /*** TopLeft header çizim kodu. ***/
            this.fileGeoGridView1.TopLeftHeaderCell = new DarkColumnHeaderDrawer(null, FileGeo.UIComponents.Resources.iconpng);
            this.Column1.HeaderCell = new DarkColumnHeaderDrawer(this.Column1.HeaderText);
            this.Column2.HeaderCell = new DarkColumnHeaderDrawer(this.Column2.HeaderText);
        }

        public FileMetadata(ShellObject FileShellObject)
            : this()
        {
            this.FileShellObject = FileShellObject;
        }

        private void DisplayProperties(ShellObject selectedSO)
        {
            // Display some basic properties
            if (selectedSO != null)
            {
                this.Text = String.Format("File metadata informations for: {0}", selectedSO.Name);
                // display properties for this folder, as well as a thumbnail image.
                selectedSO.Thumbnail.CurrentSize = new System.Windows.Size(256, 256);
                pictureBox1.Image = selectedSO.Thumbnail.Bitmap;

                // show the properties
                AddProperty("Name", selectedSO.Name);
                AddProperty("Path", selectedSO.ParsingName);
                AddProperty("Type of ShellObject", selectedSO.GetType().Name);
                foreach (IShellProperty prop in selectedSO.Properties.DefaultPropertyCollection)
                {
                    if (prop.ValueAsObject != null)
                    {
                        try
                        {
                            if (prop.ValueType == typeof(string[]))
                            {
                                string[] arr = (string[])prop.ValueAsObject;
                                string value = "";
                                if (arr != null && arr.Length > 0)
                                {
                                    foreach (string s in arr)
                                        value = value + s + "; ";
                                    if (value.EndsWith("; "))
                                        value = value.Remove(value.Length - 2);
                                }
                                AddProperty(prop.CanonicalName, value);
                            }
                            else
                                AddProperty(prop.CanonicalName, prop.ValueAsObject.ToString());
                        }
                        catch
                        {
                            // Ignore
                            // Accessing some properties might throw exception.
                        }
                    }
                }
            }
        }

        private void AddProperty(string property, string value)
        {
            if (!string.IsNullOrEmpty(property))
                fileGeoGridView1.Rows[fileGeoGridView1.Rows.Add(property, value)].HeaderCell = new DarkRowHeaderDrawer();
        }

        private void FileMetadata_Load(object sender, EventArgs e)
        {
            DisplayProperties(this.FileShellObject);
        }
    }
}


这篇关于我如何在C#中显示Wav文件的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆