Results 1 to 5 of 5

Thread: Retrieve File Path ?

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    43

    Retrieve File Path ?

    How do retrieve the path of a File open in a foreign process ?

    Thank you.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Retrieve File Path ?

    Welcome to the forums.

    What do you mean by "foreign process"?

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2005
    Posts
    43

    Re: Retrieve File Path ?

    Quote Originally Posted by Hack
    Welcome to the forums.

    What do you mean by "foreign process"?

    I mean a running application . It could be Word, Excel, NotePad ...

    However, I do not want to use Automation for this as not every application supports it.

    Thanks.

  4. #4
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: Retrieve File Path ?

    To get the file path you can use the mainmodule property of the process class. I used winamp in the example. Note that GetProcessesByName creates an array and populates it. An array, because there can be more than one processes with the same name - like 3 notepad windows.


    VB Code:
    1. Dim Proc As Process() = Process.GetProcessesByName("winamp")
    2.  
    3. lbl1.Text = Proc(0).MainModule.FileName


    EDIT: Upsss, I noticed too late it is the API section. Still, you can do it this way without API calls.
    Last edited by Half; Dec 19th, 2005 at 11:08 PM.

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Retrieve File Path ?

    Is this what you mean?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width