Exemple #1
0
        /// <summary>
        /// Gets the small icon for a file
        /// </summary>
        /// <param name="file">The path to the file</param>
        /// <returns>An Icon object with the file icon</returns>
        public static Icon GetSmallIcon(string file)
        {
            FileIcon fi = new FileIcon(file);

            fi.Flags = fi.Flags
                       | SHGetFileInfoConstants.SHGFI_SMALLICON &
                       ~(SHGetFileInfoConstants.SHGFI_DISPLAYNAME | SHGetFileInfoConstants.SHGFI_TYPENAME |
                         SHGetFileInfoConstants.SHGFI_ATTRIBUTES | SHGetFileInfoConstants.SHGFI_EXETYPE);

            fi.GetInfo();

            Icon icon = fi.ShellIcon;

            fi.Dispose();

            return(icon);
        }
Exemple #2
0
 /// <summary>
 /// Constructs a new instance of the FileIcon class
 /// and retrieves the information specified in the 
 /// flags.
 /// </summary>
 /// <param name="fileName">The filename to get information
 /// for</param>
 /// <param name="flags">The flags to use when extracting the
 /// icon and other shell information.</param>
 public FileIcon(string fileName, FileIcon.SHGetFileInfoConstants flags)
 {
     this.fileName = fileName;
     this.flags = flags;
     GetInfo();
 }
Exemple #3
0
        /// <summary>
        /// Gets the small icon for a file
        /// </summary>
        /// <param name="file">The path to the file</param>
        /// <returns>An Icon object with the file icon</returns>
        public static Icon GetSmallIcon( string file )
        {
            FileIcon fi = new FileIcon( file );

            fi.Flags = fi.Flags
                | SHGetFileInfoConstants.SHGFI_SMALLICON &
                ~(SHGetFileInfoConstants.SHGFI_DISPLAYNAME | SHGetFileInfoConstants.SHGFI_TYPENAME |
                SHGetFileInfoConstants.SHGFI_ATTRIBUTES | SHGetFileInfoConstants.SHGFI_EXETYPE );

            fi.GetInfo();

            Icon icon = fi.ShellIcon;
            fi.Dispose();

            return icon;
        }