/// <summary> /// Initialize a new instance of the <see cref="ShellPropertyWriter" /> class /// to the specified <see cref="ShellObject" />. /// </summary> /// <param name="shellObject"></param> internal ShellPropertyWriter(ShellObject shellObject) { Contract.Requires <ArgumentNullException>(shellObject != null); try { this.Store = ShellPropertyStore.CreateWritable(shellObject); } catch (InvalidComObjectException e) { throw new ShellException(ErrorMessages.ShellPropertyUnableToGetWritableProperty, e); } catch (InvalidCastException) { throw new ShellException(ErrorMessages.ShellPropertyUnableToGetWritableProperty); } }
/// <summary> /// Clear property value. /// </summary> public void ClearValue() { try { using (var writableStore = ShellPropertyStore.CreateWritable(this.ShellObject)) { writableStore.ClearValue(this.PropertyKey); writableStore.Commit(); } } catch (InvalidComObjectException e) { throw new ShellException(ErrorMessages.ShellPropertyUnableToGetWritableProperty, e); } catch (InvalidCastException e) { throw new ShellException(ErrorMessages.ShellPropertyUnableToGetWritableProperty, e); } }