How to retrieve the actual path of the All Microsoft word files if it is saved in drive. For example I have multiple ms word processes running and these are saved somewhere in the drive. How can I retrieve full path? eg "C:\Users\abc\Desktop\testnotpad.docx" Using below code I can get the notepad process detail, but the same code with little changes "WINWORD.exe" is not working for ms word.
string wmiQuery = string.Format("select CommandLine from Win32_Process where Name='{0}'", "notepad.exe");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmiQuery);
ManagementObjectCollection retObjectCollection = searcher.Get();
foreach (ManagementObject retObject in retObjectCollection)
{
string CommandLine = retObject["CommandLine"].ToString();
string path = CommandLine.Substring(CommandLine.IndexOf(" ") + 1, CommandLine.Length - CommandLine.IndexOf(" ") - 1);
}