Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. getting File path??

getting File path??

Scheduled Pinned Locked Moved C#
csharptutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Venkatesh P
    wrote on last edited by
    #1

    How to get the file path on mouse right click in c#?

    Thanks & Regards, Venkat

    B N 2 Replies Last reply
    0
    • V Venkatesh P

      How to get the file path on mouse right click in c#?

      Thanks & Regards, Venkat

      B Offline
      B Offline
      Bhupi Bhai
      wrote on last edited by
      #2

      Please search on msdn first ..... then search on google ..... followed by looking in the previous posts ...... If you still do not get answers, post a message here ... Regards, Bhupi Bhai.

      V 1 Reply Last reply
      0
      • B Bhupi Bhai

        Please search on msdn first ..... then search on google ..... followed by looking in the previous posts ...... If you still do not get answers, post a message here ... Regards, Bhupi Bhai.

        V Offline
        V Offline
        Venkatesh P
        wrote on last edited by
        #3

        I had posted this message only after searching in google and msdn.. 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 -- modified at 5:19 Wednesday 3rd January, 2007

        Thanks & Regards, Venkat

        1 Reply Last reply
        0
        • V Venkatesh P

          How to get the file path on mouse right click in c#?

          Thanks & Regards, Venkat

          N Offline
          N Offline
          Nader Elshehabi
          wrote on last edited by
          #4

          What you are talking about is called Windows Shell programming -not context menu:)-. In CodeProject there is a very good section about Shell programming. i think you can find the anwer there. Click here[^].

          Regards:rose:

          V 1 Reply Last reply
          0
          • N Nader Elshehabi

            What you are talking about is called Windows Shell programming -not context menu:)-. In CodeProject there is a very good section about Shell programming. i think you can find the anwer there. Click here[^].

            Regards:rose:

            V Offline
            V Offline
            Venkatesh P
            wrote on last edited by
            #5

            I agree that this is windows shell programming. In that path is generated by args[0]. 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 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? Thanks & Regards, Venkat

            N 1 Reply Last reply
            0
            • V Venkatesh P

              I agree that this is windows shell programming. In that path is generated by args[0]. 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 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? Thanks & Regards, Venkat

              N Offline
              N Offline
              Nader Elshehabi
              wrote on last edited by
              #6

              Venkatesh.P wrote:

              How to assign that value to the textbox?

              Simple. In your Main method

              [STAThread]
              static void Main(string[] args)
              {
              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);
              Application.Run(new Form1(args[0]));
              }

              and in Modify your form constructor to this

              Form1(string thePath)
              {
              MyFileName = thePath;
              //more code
              }

              PS. The first argument would be the path to your exe file BTW, and the second argument is the "%1" command which is used to instruct the program to open the file -not print it for example-. The Thrid argument -i.e. args[2]- I bilieve is what you are looking for. Try to show them one by one in MessageBoxs ro see the value of each before deciding which to pass to the Form's constructor.

              Regards:rose:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups