Windows Explorer context menu file path??

Last post 01-04-2007, 1:37 AM by hannibal. 2 replies.
Sort Posts: Previous Next
  •  01-03-2007, 4:30 AM Post number 11922

    Windows Explorer context menu file path??

    I have a windows based application in c#. On Windows explorer context menu i added one context menu item named "MyContext" . when the user  right clicks on a file or folder, i have "MyContext" menu(This is the context menu item that i have added to the windows explorer context menu). When i click "MyContext" menu, i have to execute one application. In that application page load, i want to get the file or folder path that the user right clicked.

    How to get that file path?? Please help

  •  01-03-2007, 7:34 AM Post number 11928 in reply to post number 11922

    • Damon is not online. Last active: 12-02-2008, 6:48 PM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Acorn Archimedes

    Re: Windows Explorer context menu file path??

    Not completely sure, but I would think that the information is being passed to your application as a command-line parameter.  Find your "Main" method that acts as the entry point to your C# app.  It probably looks like this:

    static void Main()

    because VS.NET IDE doesn't include the args parameter in your Main method for WinForms by default for some reason.  All you have to do is make it look like this:

    static void Main(string[] args)

    And you should be able to get command-line arguments that are hopefully being passed in.


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
  •  01-04-2007, 1:37 AM Post number 12140 in reply to post number 11928

    Re: Windows Explorer context menu file path??

    Thank You for the reply. I have an application, which contains a tab control. Inside the tabcontrol i am having a textbox. I am getting the string args[0] value from the program.cs file. I want to assign the string args[0] value to the textbox. How to assign that value to the textbox? This is what i have done:

    This is the program.cs file

      static class Program
        {
     public static string pathkey;

            public static string path
            {
                get
                {
                    return pathkey;
                }
                set
                {
                    pathkey = value;
                }
            }
     [STAThread]
            static void Main(string[] args)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
                Form1 objform = new Form1();
                try
                {
                 Program.pathkey= args[0].ToString ();
                   
                }
                catch (Exception ex)
                {
                }

    Form1.cs
    *********
    In my form1 load, i am assigning the value to the textbox

     txtLocation.Text = Program.pathkey.ToString();

    But i am not able to get the value?

    In registry i have the entry as C:\Documents and Settings\venkadeshp\My Documents\Visual Studio 2005\Projects\HCI_DMS ConsoleApplication\bin\Debug\HCI_DMS ConsoleApplication.exe %1 . But i couldnt find the file path in the string args[0] in the program.cs main function?

    Please help


View as RSS news feed in XML