CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2000
    Posts
    670

    Question Get current path

    How do I get the current path?

  2. #2
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    Directory.GetCurrentDirectory() for getting the current working directory or,

    System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase property if you need the directory where your executable file is stored...

    Martin

  3. #3
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    adding to martin,

    Application.ExecutablePath gives you the executable path.

    - Software Architect

  4. #4
    Join Date
    Nov 2000
    Location
    USA
    Posts
    179
    Hi!
    Try this:
    Assembly assembly = Assembly.GetExecutingAssembly();
    string fileName = assembly.Location;

  5. #5
    Join Date
    Mar 2003
    Posts
    17
    Assembly assembly = Assembly.GetExecutingAssembly();
    string fileName = assembly.Location;

    Seems this will return the assembly path. So if your code is in a library, it will be the path of the library, not the path of the calling executive file.

    Use Assembly.GetCallingAssembly instead if you want to find the calling executive path.

  6. #6
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    I guess originally RYE reffered to application's current path
    - Software Architect

  7. #7
    Join Date
    Aug 2000
    Posts
    670

    Question

    10x a lot.
    Yes, I reffered to application's current path, but how can I get it without the exe?
    What manipulation on Application.ExecutablePath can I do inorder to get it without the exe in the end?

  8. #8
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    the thing is .NET Assembley /DLL is always associated with some .exe either way. you can't run the dll on its own. so you will need to consider exe.
    what all you are trying to do anyway
    - Software Architect

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

Featured