Re: CFileDialog GetFileName()
Hi Jose,
I read somewhere that there was a problem with GetFileName() on files longer
than 64 chars, but I haven't been able to reproduce the problem and I can't
seem to find anything else on the problem. This may be what you are seeing
since, as Joe pointed out, you are getting 63 characters. It may have
something to do with the characters in the file name, but if you can get the
name from the something like:
//
// Returns the file portion from a path
//
CString GetFileOnly(LPCTSTR Path)
{
// Strip off the path and return just the filename part
CString temp = (LPCTSTR) Path; // Force CString to make a copy
::PathStripPath(temp.GetBuffer(0));
temp.ReleaseBuffer(-1);
return temp;
}
Maybe that would work OK for you as a work around. I'll be sure to post if
I come up with anything else, but I Googled around and it just doesn't make
much sense what it happening to you. You may want to just trace into the
GetFileName() function to see if you can determine more about what is going
on, bu this work around would allow you to easily get the filename from the
GetPathName() function.
Tom
"joseramonbravo" <joseramonbravo@discussions.microsoft.com> wrote in message
news:01664575-CE8E-4E3B-928B-68D05ED39B79@microsoft.com...
Joe:
Thank you for your answer.
cfd.DoModal() does actually return IDOK.
I've replied to a previous contributor (Dave). So if you please read my
comments to him you could possibly make further contribution.
Jos??-Ram??n
"Joseph M. Newcomer" wrote:
See below...
On Sat, 24 Mar 2007 10:56:05 -0700, joseramonbravo
<joseramonbravo@discussions.microsoft.com> wrote:
------ I have had trouble with the following code:
CFileDialog cfd(TRUE);
cfd.DoModal();
****
if(cfd.DoModal() != IDOK)
return; // or other appropriate response
*****
CString pf,nf;
*****
Avoid commas in declaration lists. One variable, one line. Otherwise
the code becomes
unreadable. Furthermore, you can declare and initialize it in one line.
CString pf = cfd.GetPathName();
CString nf = cfg.GetFileName();
****
pf=cfd.GetPathName();
nf=cfd.GetFileName();
------ The trouble is that with a path
C:\Documents and Settings\JR\Mis documentos\Introduzca los datos
necesarios
para realizar la b??squeda del facultativo.doc
------ pf=cfd.GetPathName() works right but
------ nf=cfd.GetFileName() works badly obtaining
Introduzca los datos necesarios para realizar la b??squeda del f
------ instead of the correct
Introduzca los datos necesarios para realizar la b??squeda del
facultativo.doc
****
How do you know this? Did you do
TRACE("nf = \"%s\"\n", nf);
or did you just use the debugger to examine it? Note that the debugger
only shows the the
first few characters of a string. Had it struck you as suspicous that
there are 63
characters in this string?
joe
*****
------ CAN ANYBODY HELP TO SOLVE THE MISTERY?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm