Results 1 to 4 of 4

Thread: [RESOLVED] .Exe Path

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Resolved [RESOLVED] .Exe Path

    How to get a path for .exe file and write this path in one textbox. .exe file is compiled in Visual Studio 2005.

    Thanks.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: .Exe Path

    My.Application.Info.DirectoryPath

  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: .Exe Path

    The code below shows how to get this information

    Code:
            Console.Write(Application.ExecutablePath)
            Console.WriteLine(IO.Path.GetDirectoryName(Application.ExecutablePath))
            Console.WriteLine(IO.Path.GetFileName(Application.ExecutablePath))
    So if the path/file name was TextBox1.Text = IO.Path.GetDirectoryName("C:\Data\kevin.txt")

    Code:
    TextBox1.Text = IO.Path.GetDirectoryName("C:\Data\kevin.txt")
    Returns
    Code:
    C:\Data
    Even if the file does not exist you still get the path.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: .Exe Path

    Yes, that's it. Thanks.

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