Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7677267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:23:04+00:00 2026-05-31T17:23:04+00:00

In Visual Studio 2010 C++, I am reading argv[0] to get the working directory.

  • 0

In Visual Studio 2010 C++, I am reading argv[0] to get the working directory.

In debug mode it is definitely showing the full path of the directory and the exe file name itself (as expected)

In release mode it ONLY has the program .exe name, rather than the full working path.

  1. why?
  2. How to get working directory?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:23:05+00:00Added an answer on May 31, 2026 at 5:23 pm

    MSVC will place the command used to launch the executable into argv[0] – this has nothing to do with the current working directory.

    For example, if the command used to launch foo.exe is:

    • foo, and the executable i found by searching the path, argv[0] will be foo
    • c:\foos-dir\foo, (the path will is not searched) argv[0] will be c:\foos-dir\foo
    • foo.exe, argv[0] will be foo.exe

    etc.

    You should probably get the current working directory using the Win32 GetCurrentDirectory() API or the _getcwd() runtime function.

    Here’s a short example using GetCurrentDirectory():

    TCHAR buffer[128];           
    DWORD const buffer_chars = sizeof(buffer)/sizeof(buffer[0]);
    
    DWORD result = GetCurrentDirectory( buffer_chars, buffer);
    
    if ((result == 0) || (result >= buffer_chars)) {
        puts("problem getting the working directory");        
        exit(1);
    }
    
    printf( "Current working directory: %s\n", buffer);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working in Design mode on Visual Studio 2010... I am trying to get an
I am using the Visual Studio 2010 RC. Sometimes when I am working on
I was reading this article Build Your First Cloud Application Using Visual Studio 2010
Is Visual Studio 2010 compatible with MVC 1.0 Hello guys, Thanks for reading in
I have developed a word 2007 add-in using Visual Studio 2010, everything is working
Visual Studio 2010 offers a lot of comfortable tools for unit testing via its
Visual Studio 2010 RC -> Silverlight Application We have a library of images that
Since Visual Studio 2010 is slated for release in March of 2010 and HTML
In Visual Studio 2010 Beta 2 I created a new navigation Silverlight application. Without
In Visual Studio 2010, when you say new Item, you can see Asp.NET Handler

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.