private TransFileObject WrapObject(IPortableDeviceProperties properties, string objectId) { IPortableDeviceKeyCollection keys; properties.GetSupportedProperties(objectId, out keys); IPortableDeviceValues values; properties.GetValues(objectId, keys, out values); // Get the name of the object string name; var property = new _tagpropertykey(); property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); property.pid = 4; try { values.GetStringValue(property, out name); } catch (COMException e) { name = "(non name)"; } // Get the original name of the object string OriginalName; property = new _tagpropertykey(); property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); property.pid = 12; try { values.GetStringValue(property, out OriginalName); } catch (COMException e) { OriginalName = ""; } // Get last write time DateTime updatetime = new DateTime(); property = new _tagpropertykey(); property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); property.pid = 19; try { string value; values.GetStringValue(property, out value); string format = "yyyy/MM/dd:HH:mm:ss.fff"; updatetime = DateTime.ParseExact(value, format, null); } catch (COMException e) { //updatetime = DateTime.Now; } // Get the type of the object Guid contentType; property = new _tagpropertykey(); property.fmtid = new Guid(0xEF6B490D, 0x5CD8, 0x437A, 0xAF, 0xFC, 0xDA, 0x8B, 0x60, 0xEE, 0x4A, 0x3C); property.pid = 7; try { values.GetGuidValue(property, out contentType); } catch (COMException e) { return(new TransFileObject(name, null, updatetime, TransFileObject.ObjectKind.DIR)); } Guid folderType = new Guid(0x27E2E392, 0xA111, 0x48E0, 0xAB, 0x0C, 0xE1, 0x77, 0x05, 0xA0, 0x5F, 0x85); Guid functionalType = new Guid(0x99ED0160, 0x17FF, 0x4C44, 0x9D, 0x98, 0x1D, 0x7A, 0x6F, 0x94, 0x19, 0x21); if (contentType == folderType || contentType == functionalType) { return(new TransFileObject(name, objectId, updatetime, TransFileObject.ObjectKind.DIR)); } if (OriginalName.CompareTo("") != 0) { name = OriginalName; } return(new TransFileObject(name, objectId, updatetime, TransFileObject.ObjectKind.FILE)); }