Solved

Get current directory in VC++

Posted on 2004-04-15
5
1,951 Views
Last Modified: 2007-12-19
Hi,

How to get current working directory in VC++?

Thanks in advance,
Pampa
0
Comment
Question by:pampa_analytica
5 Comments
 
LVL 7

Accepted Solution

by:
leflon earned 35 total points
ID: 10831775
Hi pampa_analytica,

on win system you can use the getcwd(..) func

#include <direct.h>
#include <stdlib.h>
#include <stdio.h>

void main( void )
{
   char buffer[_MAX_PATH];

   /* Get the current working directory: */
   if( _getcwd( buffer, _MAX_PATH ) == NULL )
      perror( "_getcwd error" );
   else
      printf( "%s\n", buffer );
}

hth
leflon
0
 
LVL 16

Expert Comment

by:nonubik
ID: 10831829
0
 
LVL 2

Expert Comment

by:dxdat99
ID: 10832623
Hi!
u can use this code
----------
CString strDirName;
GetCurrentDirectory(strDirName);
----------
good luck
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question