title: Directory right click
body: <p>I'm designing a C# WinForms program that when the user right clicks on a directory and selects the item which I added to shell context menu (which opens the .exe for my application), it runs in the background based on where the user right clicks.</p>
  
  <p>I've already figured out how to install it and add it to the correct context menu, but I can't seem to figure out the most crucial part of the program. I've already looked <a href="https://stackoverflow.com/questions/8931305/directory-path-from-right-click?noredirect=1&amp;lq=1">here</a>, but that doesn't answer my question and the answer it gives just leads to another question.</p>
  
  <p>I also realize that command line arguments exist, and that is how <a href="https://stackoverflow.com/questions/1623625/c-sharp-arguments-for-application">this question is answered.</a> When I go onto Microsoft's website about using command line arguments, it is only about using an actual command line, which I am not using.</p>
  
  <p><strong>So my question is:</strong></p>
  
  <p><em>How exactly do I get the directory path when a user right clicks a folder and choose the shell context menu which I added?</em> </p>
  
  <p>If I have to use a command line in the background, that is fine I just need to be able to get and send the directory path to my program. </p>
  
  <p>Here is relevant code for how I use the entered directory. In essence source is the directory path that I want when the user right clicks. </p>
  
  <pre><code>private void recursiveCheck(string source)
  {
      string[] directories = Directory.GetDirectories(source);
      foreach(string directory in directories)
      {
          string test = new DirectoryInfo(directory).Name;
          if (test.Length &gt;= 3 &amp;&amp; (test.Substring(test.Length - 3).Equals("val", StringComparison.InvariantCultureIgnoreCase) || (test.Substring(test.Length - 3).Equals("ash", StringComparison.InvariantCultureIgnoreCase)))
          {
              if (Directory.Exists(directory + "\\STARTUP"))
                  testing_dir(directory);
              else
              {
                  MessageBox.Show("Error! Startup folder does not exist in: " + test);
                  Application.Exit();
              }
          }
          else
              recursiveCheck(directory);
      }
  }
  </code></pre>