Ejemplo n.º 1
0
        /// <summary>
        /// This method formats each property value and prints them inside the
        /// console with their canonical names.
        /// </summary>
        private static void printProperties(List <IShellProperty> propertyList)
        {
            int sizeMaxCanName    = getLongestCanonicalName(propertyList);
            int countedProperties = 0;

            //Set window width to maximum possible text row width:
            if (sizeMaxCanName + 112 <= Console.LargestWindowWidth)
            {
                Console.SetWindowSize(sizeMaxCanName + 112, Console.WindowHeight);
            }

            //Prints each property value with its canonical name:
            foreach (IShellProperty property in propertyList)
            {
                string canonicalName = property.CanonicalName;
                string propertyValue = "";
                countedProperties++;

                try
                {
                    //Gets a string representation of the property with a proper format using the installed windows culture:
                    propertyValue = property.FormatForDisplay(PropertyDescriptionFormatOptions.None);
                }
                catch (ShellException)
                {
                    //Return the property value as a string if formatting fails and a ShellException was thrown:
                    propertyValue = getStringPropertyValue(property);
                }

                //Change the property text value to a proper output format when the text is too long:
                propertyValue = FileMetadataReader.insertWordWrap(propertyValue, sizeMaxCanName);

                //Print the canonical name with PadRight to have each property text value on the same width:
                Console.WriteLine(canonicalName.PadRight(sizeMaxCanName + 10, '.') + " " + propertyValue);
            }

            Console.WriteLine("Counted Items: " + countedProperties);
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     FileMetadataReader.run();
 }