title: Get filename by process
body: <p>I'm trying to retrieve the filename of a current process.</p>
  
  <p>ie: If i have the file "test.txt" opened in Notepad, I need to get something like "c:\folder\test.txt"</p>
  
  <p>The code below returns process informations, including the software path. (ie: "c:\windows\system32\notepad.exe").</p>
  
  <pre><code>[DllImport("user32.dll", EntryPoint = "GetForegroundWindow", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
  public static extern int GetForegroundWindow();
  
  [...]
  
  public static string GetFilePathName()
  {
      uint procId = 0;
      int hWnd = GetForegroundWindow();
      GetWindowThreadProcessId(hWnd, out procId);
      var proc = Process.GetProcessById((int)procId);
  }
  </code></pre>
  
  <p>Is it possible to use this Process Class to achieve the opened filename/path the the current process is handling?</p>