0

How to find the full path of all opened files of different applications i.e Word, pdf reader or Excel?
I tried attached code, but only found the file names rather then complete path of files.

        foreach (Process p in Process.GetProcessesByName("excel"))
            try
            {
                if (p.MainWindowTitle.Length > 0)
                {
                    Console.WriteLine("======================");
                    Console.WriteLine("Window Title:" + p.MainWindowTitle.ToString());
                    Console.WriteLine("Process Name:" + p.ProcessName.ToString());
                    Console.WriteLine("Window Handle:" +  p.MainWindowHandle.ToString());     
                }
            }
            catch { }
virious
  • 571
  • 1
  • 8
  • 27

1 Answers1

0

This worked for me:

Console.WriteLine("Full Path:" +  p.MainModule.FileName);
Hogan
  • 69,564
  • 10
  • 76
  • 117
  • this returns the full path to application, not the full paths by the files currently open by the application, which is what is asked for, I believe (hard to tell actually..) – Fredrik Mar 07 '13 at 14:07