//------------------------------------------------------------------------------ // Name: DeleteAttrib() // Desc: Delete the attribute at the specified index. //------------------------------------------------------------------------------ bool DeleteAttrib(string pwszFileName, ushort wStreamNum, ushort wAttribIndex) { try { IWMMetadataEditor MetadataEditor; IWMHeaderInfo3 HeaderInfo3; WMFSDKFunctions.WMCreateEditor(out MetadataEditor); MetadataEditor.Open(pwszFileName); HeaderInfo3 = ( IWMHeaderInfo3 )MetadataEditor; HeaderInfo3.DeleteAttribute(wStreamNum, wAttribIndex); MetadataEditor.Flush(); MetadataEditor.Close(); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } return(true); }
//------------------------------------------------------------------------------ // Name: AddAttrib() // Desc: Add an attribute with the specifed language index. //------------------------------------------------------------------------------ bool AddAttrib(string pwszFileName, ushort wStreamNum, string pwszAttribName, ushort wAttribType, string pwszAttribValue, ushort wLangIndex) { try { IWMMetadataEditor MetadataEditor; IWMHeaderInfo3 HeaderInfo3; byte[] pbAttribValue; int nAttribValueLen; WMT_ATTR_DATATYPE AttribDataType = ( WMT_ATTR_DATATYPE )wAttribType; ushort wAttribIndex = 0; if (!TranslateAttrib(AttribDataType, pwszAttribValue, out pbAttribValue, out nAttribValueLen)) { return(false); } WMFSDKFunctions.WMCreateEditor(out MetadataEditor); MetadataEditor.Open(pwszFileName); HeaderInfo3 = ( IWMHeaderInfo3 )MetadataEditor; HeaderInfo3.AddAttribute(wStreamNum, pwszAttribName, out wAttribIndex, AttribDataType, wLangIndex, pbAttribValue, (uint)nAttribValueLen); MetadataEditor.Flush(); MetadataEditor.Close(); } catch (Exception e) { Console.WriteLine(e.Message); return(false); } return(true); }