Re: Directory of my running app.
This is a subject that comes up once a month around here: (sometimes a
simple search will save you alot of time and grief)
http://groups.google.com/group/microsoft.public.vc.mfc/search?group=microsoft.public.vc.mfc&q=application+directory
Obviously GetCurrentDirectory will give the applications current directory.
If your application hasn't changed its directory using SetCurrentDir or
chdir or using a CFileDialog without OFN_NOCHANGEDIR flag then the directory
returned is the directory where the application file is in if the user
double clicked on your exe, or the directory in Start in field of a
shortcut.
GetModuleFilename on the other hand will give you the fullpath to the exe,
where you can get the directory part using
//
// Returns the folder portion from a path
//
CString GetFolderOnly(LPCTSTR Path)
{
// Strip off the file name so we can direct the file scanning dialog to
go
// back to the same directory as before.
CString temp = (LPCTSTR) Path; // Force CString to make a copy
::PathRemoveFileSpec(temp.GetBuffer(0));
temp.ReleaseBuffer(-1);
return temp;
}
AliR.
"RAN" <nijenhuis@wish.nl> wrote in message
news:1187987374.527648.133060@l22g2000prc.googlegroups.com...
Hi,
How do i get the directoryname of my running app. ?
Should i use GetCurrentDirectory() ?
I want to create directories in the same directory where my app.
(server) is located.