@@ -242,7 +242,8 @@ public void Save(CFStream cfStream)
242
242
243
243
ps . PropertySet1 = new PropertySet
244
244
{
245
- NumProperties = ( uint ) this . UserDefinedProperties . Properties . Count ( ) ,
245
+ // Number of user defined properties, plus 1 for the name dictionary
246
+ NumProperties = ( uint ) this . UserDefinedProperties . Properties . Count ( ) + 1 ,
246
247
PropertyIdentifierAndOffsets = new List < PropertyIdentifierAndOffset > ( ) ,
247
248
Properties = new List < Interfaces . IProperty > ( ) ,
248
249
PropertyContext = UserDefinedProperties . Context
@@ -251,13 +252,21 @@ public void Save(CFStream cfStream)
251
252
ps . FMTID1 = new Guid ( WellKnownFMTID . FMTID_UserDefinedProperties ) ;
252
253
ps . Offset1 = 0 ;
253
254
255
+ // Add the dictionary containing the property names
256
+ IDictionaryProperty dictionaryProperty = new DictionaryProperty ( ps . PropertySet1 . PropertyContext . CodePage )
257
+ {
258
+ Value = this . UserDefinedProperties . PropertyNames
259
+ } ;
260
+ ps . PropertySet1 . Properties . Add ( dictionaryProperty ) ;
261
+ ps . PropertySet1 . PropertyIdentifierAndOffsets . Add ( new PropertyIdentifierAndOffset ( ) { PropertyIdentifier = 0 , Offset = 0 } ) ;
262
+
263
+ // Add the properties themselves
254
264
foreach ( var op in this . UserDefinedProperties . Properties )
255
265
{
256
266
ITypedPropertyValue p = PropertyFactory . Instance . NewProperty ( op . VTType , ps . PropertySet1 . PropertyContext . CodePage ) ;
257
267
p . Value = op . Value ;
258
268
ps . PropertySet1 . Properties . Add ( p ) ;
259
269
ps . PropertySet1 . PropertyIdentifierAndOffsets . Add ( new PropertyIdentifierAndOffset ( ) { PropertyIdentifier = op . PropertyIdentifier , Offset = 0 } ) ;
260
-
261
270
}
262
271
}
263
272
0 commit comments