title: Get folder path from drag and drop on C# console application .exe
body: <p>I have written this simple program that when a file gets dragged on the .exe it copies the file's path to the clipboard and exits. The problem is it doesn't seem to work with folders and I would like to add compatibility for folders as well.</p>
  
  <p>Here is the code: </p>
  
  <pre><code>using System;
  using System.IO;
  using System.Windows.Forms;
  
  namespace GetFilePath
  {
      class Program
      {
          [STAThread]
          static void Main(string[] args)
          {
              Console.Title = "Getting path...";
              if (args.Length &gt; 0 &amp;&amp; File.Exists(args[0]))
              {
                  string path;
                  path = args[0];
                  Console.WriteLine(path);
                  Clipboard.Clear();
                  Clipboard.SetText(path);
                  MessageBox.Show("Path copied to clipboard", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
              }
          }
      }
  }
  </code></pre>
  
  <p>Any suggestions? I know the code might not be optimal for what I would like to achieve, but it works, although feel free to leave any comments regarding the improvement of the code.</p>