fonix232
fonix232

Reputation: 2195

Simple file and folder view in C#

I have seen an application recently what had two simple controls (a treeView and a detailed ListView) what were used for listing directories and files. I know how to do this, but it had another nice feature other than listing files: it loaded info from the system shell, like icons of folders, file specifications (file types mostly, inherited from the system, so if I had an application what modified the SVG file type to "Unknown vectorgraphic stuff" then it showed all SVG file's type as this string before).

I would like to ask You, that how could I make these features easily without using any third party library?

Upvotes: 0

Views: 2424

Answers (2)

logicnp
logicnp

Reputation: 5836

  1. To get the file icon, use System.Drawing.Icon.ExtractAssociatedIcon.
  2. To get the file type, you need to use the Win32 SHGetFileInfo function.
  3. To get date modified, file size, etc, you can use DirectoryInfo and FileInfo classes.

You can also consider using ready-made controls like Shell MegaPack which show files/folders like this with same icons, details, menus, etc

Upvotes: 1

Axarydax
Axarydax

Reputation: 16603

you can get icon for a file by System.Drawing.Icon.ExtractAssociatedIcon()...

Upvotes: 1

Related Questions