Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the current directory?

I am trying to read a file which I read previously successfully. I am reading it through a library, and I am sending it as-is to the library (i.e. "myfile.txt"). I know that the file is read from the working/current directory.

I suspect that the current/working directory has changed somehow. How do i check what is the current/working directory?

like image 891
lital maatuk Avatar asked Jan 26 '11 17:01

lital maatuk


2 Answers

Since you added the visual-c++ tag I'm going to suggest the standard windows function to do it. GetCurrentDirectory

Usage:

TCHAR pwd[MAX_PATH];
GetCurrentDirectory(MAX_PATH,pwd);
MessageBox(NULL,pwd,pwd,0);
like image 189
monoceres Avatar answered Oct 05 '22 06:10

monoceres


Boost filesystem library provides a clean solution

current_path()
like image 27
Dr G Avatar answered Oct 05 '22 05:10

Dr G