Axarydax
Axarydax

Reputation: 16603

Showing windows (file/directory) context menu in c# winforms application

I'm trying to display standard file/directory context menu in WinForms application - I'd like to enable the user to do things with files in my application as he could in Explorer.

There should be two options

Could you please point me in the right direction? Thanks

Upvotes: 8

Views: 5009

Answers (2)

Kevin McCormick
Kevin McCormick

Reputation: 2398

This may prove to be very challenging, so I propose two solutions:

  1. (Easy) Using the library that Groky suggested, do what is done in FolderSizes. The Explorer context menu is shown as a sub-context-menu. You can simulate this by displaying the explorer menu when the "Explorer Operation" item is hovered.

    enter image description here

  2. (Hard) If that is insufficient, you can go all the way and get the menu items from the shell, and create your own menu. This CodeProject article ( http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx ) goes through the process of enumerating and invoking shell commands for a specific shell object, and how to enumerate submenus.

Upvotes: 5

Grokys
Grokys

Reputation: 16526

I have written a .NET library to allow this. You can find it here:

http://gong-shell.sourceforge.net/

The class you're looking for is ShellContextMenu within that library.

Upvotes: 8

Related Questions