I have a similar problem to this: Current working directory is visual studio directory
Except that I am working with a C++ project in Visual Studio. Any suggestions?
For example if I try the solution in the following post: GetCurrentDirectory for startup App. c++
I get this:
"C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE"
But I want it to be the Debug folder under my project/solution folders.
Using the _fullpath command allowed me to extract the current directory. For example you can modify the example code on the linked page :
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <direct.h>
void PrintFullPath( char * partialPath )
{
char full[_MAX_PATH];
if( _fullpath( full, partialPath, _MAX_PATH ) != NULL )
printf( "Full path is: %s\n", full );
else
printf( "Invalid path\n" );
}
int main( void )
{
// Get current directory
PrintFullPath( ".\\" );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With