[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 880
  • Last Modified:

Current Directory

I have a question regarding GetCurrentDirectory SDK Function. It takes two parameters one the length of hte buffer and the character string.

I wanted to know whether there are some other functions in MFC to get the current directory which can circumvent the Length parameter. Is there any way to get the Current Working directory using MFC and something which returns CString.
0
karthikr
Asked:
karthikr
  • 2
  • 2
1 Solution
 
naveenkohliCommented:
not any as i know of...
just curious.. why you don't want to use GetCurrentDirectory..
Just set the length argumnet as MAX_FILE or you can say 255
0
 
Shay050799Commented:
try _getcwd() its stl, and u hand it the buffer
0
 
naveenkohliCommented:
oops.... MAX_FILE should read as MAX_PATH .. :)

0
 
psdavisCommented:
My favorite way...

CString strDirectory;
GetCurrentDirectory( strDirectory.GetBufferSetLength( _MAX_PATH ));
strDirectory.ReleaseBuffer( );

Phillip
0
 
psdavisCommented:
Oops, forgot to add that second parameter.

GetCurrentDirectory( strDirectory.GetBufferSetLength( _MAX_PATH ), _MAX_PATH );

0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now