how to get the type of the folders RRS feed

  • Question

  • I use the codes below to get the type of files.

     string ext = Path.GetExtension(sFileName);
                    string desc = (string)Registry.ClassesRoot.OpenSubKey(ext).GetValue(null);
                    typeinfo = (string)Registry.ClassesRoot.OpenSubKey(desc).GetValue(null);

    how to get the type of folders?


    Wednesday, September 18, 2013 9:55 AM


  • A folder is a folder.  There is no concept of a folder type.  Please clarify what you are trying to accomplish. 

    From what I can see by your code you are getting the file extension of a file.  From that you're trying to get the file type as defined in the Shell.  From there you're getting information about the program associated with the file type.  That seems like a really long road to get program association information.  In the shell a folder is listed as Folder but this is for standard folders.  The shell also shows "folders" that are actually junction points or virtual (i.e. Control Panel).  In general if you wanted to add new context menus or otherwise extend a folder you'll use Folder.

    Note that Win8 changed how program associations work.  Please refer to this MSDN article on how the changes may impact your code.

    You should consider using the Shell API to get the information you want.  The Shell provides an API here to get basic association information.  Refer to this interface as an alternative.

    Michael Taylor

    Wednesday, September 18, 2013 3:20 PM