Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Finding Process Path

Finding Process Path

Scheduled Pinned Locked Moved C#
questionhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lijo Rajan
    wrote on last edited by
    #1

    Hi all, How can i find out process path? i am using following code for getting process file name. i need to get the path of that file also. Can any one help me?? Process[] arrProcesses = Process.GetProcesses(); for (int i = 0; i <= arrProcesses.Length - 1; i++) { Process objProcess = arrProcesses[i]; if (objProcess.ProcessName == "WINWORD" && !(objProcess.MainWindowHandle == IntPtr.Zero)) { string FileNameDefault = objProcess.MainWindowTitle; string[] str1; str1 = FileNameDefault.Split('-'); // System.IO.Path pt=objProcess.exe FileNameDefault = str1[0]; } } Regards Lijo

    A 1 Reply Last reply
    0
    • L Lijo Rajan

      Hi all, How can i find out process path? i am using following code for getting process file name. i need to get the path of that file also. Can any one help me?? Process[] arrProcesses = Process.GetProcesses(); for (int i = 0; i <= arrProcesses.Length - 1; i++) { Process objProcess = arrProcesses[i]; if (objProcess.ProcessName == "WINWORD" && !(objProcess.MainWindowHandle == IntPtr.Zero)) { string FileNameDefault = objProcess.MainWindowTitle; string[] str1; str1 = FileNameDefault.Split('-'); // System.IO.Path pt=objProcess.exe FileNameDefault = str1[0]; } } Regards Lijo

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      objProcess.MainModule.FileName Edit: Suggestion: If you are searching for only Winword processes you can use Process.GetProcessesByName to avoid the loop and checking for the particular process name

      modified on Monday, March 2, 2009 9:46 AM

      L 1 Reply Last reply
      0
      • A ABitSmart

        objProcess.MainModule.FileName Edit: Suggestion: If you are searching for only Winword processes you can use Process.GetProcessesByName to avoid the loop and checking for the particular process name

        modified on Monday, March 2, 2009 9:46 AM

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        ABitSmart wrote:

        avoid the loop

        GetProcessesByName() returns an array, just like GetProcesses() does; it probably will be a shorter array, but you may still want to enumerate it. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


        modified on Sunday, June 12, 2011 8:58 AM

        A 1 Reply Last reply
        0
        • L Luc Pattyn

          ABitSmart wrote:

          avoid the loop

          GetProcessesByName() returns an array, just like GetProcesses() does; it probably will be a shorter array, but you may still want to enumerate it. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


          modified on Sunday, June 12, 2011 8:58 AM

          A Offline
          A Offline
          ABitSmart
          wrote on last edited by
          #4

          My intention was to make the OP aware about GetProcessesByName. Thanks for your comment :thumbsup: (edited my comment)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups