How do I get the icon associated with a file type?

后端 未结 2 1788
挽巷
挽巷 2020-12-03 09:05

I have a form that displays file information in a TabControl, and I\'d like the pages to have the file\'s icon in their tab. How do I get the icon associated with a file ty

相关标签:
2条回答
  • 2020-12-03 09:31

    CodeProject has some classes you can download.

    First get the FileAssociationInfo, and from that get the ProgramAssociationInfo. The pai object can give you the icon.

    FileAssociationInfo fai = new FileAssociationInfo(".bob");
    ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
    ProgramIcon icon = pai.DefaultIcon;
    
    0 讨论(0)
  • 2020-12-03 09:45

    System.Drawing.Icon.ExtractAssociatedIcon(string filePath)

    0 讨论(0)
提交回复
热议问题