Search code examples
c#winformsregistryfile-type

How to add File type with File icon in a listbox using c# windows Application ?


Eg: (fileIcon)a1.txt , (fileIcon)a2.pdf , (fileIcon)a3.pst Etc...

enter image description here

I have a windows form application, Actually I want to upload some files to listbox with fileIcon with file name and type. I am not getting this task! Help me out. Thanks....


Solution

  • You can add this line in your OpenFileDialog's Filter under its properties

    Image File|*.jpg|Icon files|*.ico
    

    and so on.. It's a set of a file type string and its extension format

    Image File|*.jpg
    

    define one type of file type supported, you can use multiple format for a file type name e.g.

    Image Files|*.jpg,*.png,*.bmp
    

    Or simply support All files by using following filter, but it is not recommended anyway

    All Files|*.*