Background and motivation
Right now, the Icon.ExtractAssociatedIcon method can be used to get one and only one of the icons associated with a certain file, but the file is likely to have multiple icons of different sizes and color depths associated with it. I think this method or a new similar method should return some kind of "icons descriptor" where you can iterate through every icon associated with the file specified. I notice some work was done in issue #8929 to add ExtractIcon but that really tackles a different problem of extracting an icon from the file actually containing the icon resource and not a file just associated with it. Basically I want to be able to pass in a .pdf file and get all the icons associated with PDF files on the system.
API Proposal
namespace System.Drawing;
public class Icon
{
// The existing Extract method.
public static Icon ExtractAssociatedIcon(string! filePath);
// New method to get all icons
public static IconsDescriptor ExtractAssociatedIcons(string! filePath);
}
API Usage
// Get icons descriptor
using IconsDescriptor icons = Icon.ExtractAssociatedIcons(@"C:\Path\To\my.pdf");
// e.g. save all icons to their own file
foreach (var icon in icons.AllIcons) {
using (var outputFileHandle = getNewIconHandle()) {
icon.Save(outputFileHandle);
}
}
Alternative Designs
No response
Risks
No response
Will this feature affect UI controls?
No.
Background and motivation
Right now, the
Icon.ExtractAssociatedIconmethod can be used to get one and only one of the icons associated with a certain file, but the file is likely to have multiple icons of different sizes and color depths associated with it. I think this method or a new similar method should return some kind of "icons descriptor" where you can iterate through every icon associated with the file specified. I notice some work was done in issue #8929 to addExtractIconbut that really tackles a different problem of extracting an icon from the file actually containing the icon resource and not a file just associated with it. Basically I want to be able to pass in a .pdf file and get all the icons associated with PDF files on the system.API Proposal
API Usage
Alternative Designs
No response
Risks
No response
Will this feature affect UI controls?
No.