|
-
April 17th, 1999, 04:21 AM
#1
CFileDialog
Hello,
I want to get the full filename (w/ path) of a selected file in a CFileDialog, but without
the extension (like .txt) !
CFileDialog::GetFileTitle() does, but then I have no path to the file. CFileDialog::GetPathName() receives the full path and the filename, but with the extension.
Is there any way to do what I want ?
Thanks, Dominik
Dominik Rothert
E-Mail: [email protected]
-
April 17th, 1999, 05:44 AM
#2
Re: CFileDialog
Try this:
CString fullname = CFileDialog::GetPathName(); // full path with filename
CString filename = CFileDialog::GetFileName(); // filename only
int pos = filename.ReverseFind('.'); // only find the last '.', if any
if(pos > 0){ // make sure the filename has extension
pos = fullname.ReverseFind('.');
// now get rid of extension
fullname.Left(pos); // remove the extension from filename
}
The above codes may not cover all knid of cases, for example, a file has more than one extension (text.dat.dat). Also, you can call C library function:
void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext );
to extract the full path w/ filename into separate strings and format to the string you want.
Hope this will help. Good luck.
Lynx
-
January 25th, 2002, 02:45 AM
#3
Re: CFileDialog
hi I want a File/Directory select dialog to appear after pressing a button ,and I want to store the path into buffer.I am in urgent need of this
thanks
RAJU
Rajendrappa HS.
Siemens Public Communication Networks Ltd.
Garden City, INDIA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|