Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Accessing WMF metadata with C#

, 21 Jun 2006
An article on how to use C# and the Windows Media Format SDK to read metadata in Windows Media Format files.
metadatareader_demo.zip
WMFMetadataReader
WMFMetadataReader
bin
obj
Debug
Refactor
TempPE
WMFMetadataReader.exe
Properties
Settings.settings
WMFSDKWrapper
bin
Debug
WMFSDKWrapper.dll
obj
Debug
Refactor
TempPE
Properties
metadatareader_src.zip
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WMFMetadataReader
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter = "wmv files (*.wmv)|*.wmv";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.RestoreDirectory = true;   //whether or not to remember last directory

            DialogResult Result = openFileDialog1.ShowDialog();

            ///if we get a file, put path and name in textbox
            if (Result == DialogResult.OK)
            {
                txtFileName.Text = openFileDialog1.FileName;

            }

            // Cancel button was pressed.
            else if (Result == DialogResult.Cancel)
            {
                return;
            }
        }

        private void cbFieldChooser_SelectedIndexChanged(object sender, EventArgs e)
        {
            //make sure filename has a value
            if (txtFileName.Text == "")
            {
                lblError.Visible = true;
            }
            else
            {
                MetaDataReader objMetaData = new MetaDataReader();
                txtValue.Text = objMetaData.GetFieldByName(txtFileName.Text, cbFieldChooser.SelectedItem.ToString());
            }//end else we have a file to process

        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Kris Rudin
Web Developer
United States United States
Kris Rudin is a senior developer with Ascentium corporation, with 10 years of experience including both web and Windows client software development.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.1411028.1 | Last Updated 21 Jun 2006
Article Copyright 2006 by Kris Rudin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid