contextmenu - C# : getting folder name when right click on it -


i developing windows application, need folder name while right clicking on folder operations on .

so far did following :

  1. made registry subkey in hkkey_class_root\folder\shell\(my program name)
  2. made registry subkey of program name\command [the path of program]

now made registry key displayed in folder context menu. , in application did following :

1- in program.cs

    static void main(string[] args)     {         application.enablevisualstyles();         application.setcompatibletextrenderingdefault(false);         form1 p = new form1();         if (args.length > 0)         {             p.pathkey = args[0];         }         application.run(p);     } 

2- in form1 :

    private string _pathkey;     public string pathkey     {         { return _pathkey; }         set { _pathkey = value; }     }      private void form1_load(object sender, eventargs e)     {          if (this.pathkey != null)         {            textbox1.text=pathkey;         }     } 

finally :

now when right click on folder lets example called new. textbox3.text = c:\new , far works fine if folder name new folder textbox3.text = c:\new not c:\new folder , problem if args.length > 0 display the lenght 0 not full path.

you need put %0 in registry in quotes force entire path treated single argument.
otherwise, spaces treated argument separators.

you call string.join(" ", args) manually recombine of arguments, first way better.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -