I am facing one problem while appending file extension.
I have a derived class from CFileDialog.
I am using OFN_NOVALIDATE flag while creating CFileDialog object.
According to MSDN - If we use NOVALIDATE flag then
"No default extension is added to the text, nor is text copied to the buffer specified by lpstrFileTitle."
My MFC is very weak, but I think that CString::GetBuffer() returns an internal managed buffer. The caller (and filler) of the OFN structure usually provides the buffer, and if so, you seem to be overriding the pointer given by the caller with this code. But then again, I am not sure if this is the case for you exactly.
Furthermore, you are assigning the value of strfilename to lpstrFile. I thought you wanted lpstrFileTitle.