public IEnumerator <IShellProperty> GetEnumerator() { if (this.properties == null) { using (var propertyStore = ShellPropertyStore.Create(this.ShellObject)) { var propertyCount = propertyStore.Count; this.properties = new List <IShellProperty>(propertyCount); for (var index = 0u; index < propertyCount; ++index) { var propertyKey = propertyStore.GetAt(index); try { this.properties.Add(ShellPropertyFactory.Create(propertyKey, this.ShellObject)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } } } } return(this.properties.GetEnumerator()); }
/// <summary> /// Gets the text for displaying the property value. /// </summary> /// <param name="formatFlags">Format flags.</param> /// <returns></returns> public string GetDisplayText(PropertyDescriptionFormatFlags formatFlags) { using (var store = ShellPropertyStore.Create(this.ShellObject)) { var propVar = default(PropVariant); try { store.GetPropVariant(this.PropertyKey, out propVar); return(this.Description.GetDisplayText(ref propVar, formatFlags)); } finally { propVar.Clear(); } } }
public bool TryGetDisplayText(PropertyDescriptionFormatFlags formatFlags, out string text) { using (var store = ShellPropertyStore.Create(this.ShellObject)) { var propVar = default(PropVariant); try { store.GetPropVariant(this.PropertyKey, out propVar); if (!this.Description.TryGetDisplayText(ref propVar, formatFlags, out text)) { text = String.Empty; return(false); } return(true); } finally { propVar.Clear(); } } }