} // private void ReadFileDetails(string path) { using (ShellObject shellObj = ShellObject.FromParsingName(path)) { using (ShellProperties props = shellObj.Properties) { this.WriteProperties(props); IShellProperty shellProp = props.GetProperty(SystemProperties.System.Category); ShellPropertyDescription desc = SystemProperties.GetPropertyDescription(SystemProperties.System.Category); Console.WriteLine("Prop value: " + desc.ValueType); } } }
/// <summary> /// This method collects the canonical names of all properties /// that are reflected from the given list of types. /// </summary> public void collectCanonicalNames(List <Type> types) { foreach (Type type in types) { PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propInfo in properties) { PropertyKey key = (PropertyKey)propInfo.GetValue(null); ShellPropertyDescription desc = SystemProperties.GetPropertyDescription(key); string canonicalName = desc.CanonicalName; if ((!canonicalNames.Contains(canonicalName)) && canonicalName != null) { canonicalNames.Add(canonicalName); } } } }
void DoAction(string[] args) { if (args.Length == 0 || args[0].Contains("?")) { Usage(); return; } if (args[0].Equals("-get", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length != 3) { Usage(); return; } string propertyName = args[1]; string fileName = Path.GetFullPath(args[2]); IShellProperty prop = ShellObject.FromParsingName(fileName).Properties.GetProperty(propertyName); DisplayPropertyValue(prop); } else if (args[0].Equals("-set", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length != 4) { Usage(); return; } string propertyName = args[1]; string value = args[2]; string fileName = Path.GetFullPath(args[3]); IShellProperty prop = ShellObject.FromParsingName(fileName).Properties.GetProperty(propertyName); SetPropertyValue(value, prop); } else if (args[0].Equals("-info", StringComparison.InvariantCultureIgnoreCase)) { //if (args.Length != 2) if (args.Length != 3) { Usage(); return; } string propertyName = args[1]; ShellPropertyDescription propDesc = SystemProperties.GetPropertyDescription(propertyName); ShowPropertyInfo(propertyName, propDesc); } else if (args[0].Equals("-enum", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length < 2) { Usage(); return; } string fileName = null; string filter = null; if (args.Length > 2) { filter = args[1]; fileName = Path.GetFullPath(args[2]); } else { fileName = Path.GetFullPath(args[1]); } EnumProperties(fileName, filter); } else { Usage(); return; } }