Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Current Directory

Posted on 1999-07-16
5
Medium Priority
?
879 Views
Last Modified: 2013-11-20
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
Comment
Question by:karthikr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1310195
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
 
LVL 3

Expert Comment

by:Shay050799
ID: 1310196
try _getcwd() its stl, and u hand it the buffer
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1310197
oops.... MAX_FILE should read as MAX_PATH .. :)

0
 
LVL 7

Accepted Solution

by:
psdavis earned 0 total points
ID: 1310198
My favorite way...

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

Phillip
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1310199
Oops, forgot to add that second parameter.

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

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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