CFileDialog::GetFileExt CString GetFileExt( ) const;Return ValueThe extension of the filename.ResCall this function to retrieve the extension of the filename entered into the dialog box. For example, if the name of the file entered is DATA.TXT, GetFileExt returns "TXT".If m_ofn.Flags has the OFN_ALLOWMULTISELECT flag set, this string contains a sequence of null-terminated strings, with the first string being the directory path of the file group selected, followed by the names of all files selected by the user. To retrieve file pathnames, use the GetStartPosition and GetNextPathName member functions.
详情请参阅MSDN的CFileDialog类。
CString GetFileExt( ) const;Return ValueThe extension of the filename.ResCall this function to retrieve the extension of the filename entered into the dialog box. For example, if the name of the file entered is DATA.TXT, GetFileExt returns "TXT".If m_ofn.Flags has the OFN_ALLOWMULTISELECT flag set, this string contains a sequence of null-terminated strings, with the first string being the directory path of the file group selected, followed by the names of all files selected by the user. To retrieve file pathnames, use the GetStartPosition and GetNextPathName member functions.
当我选择了不同的问题类型,并输入了一个不含后缀的新文件名
(如:kk,该文件不存在,还未建立)后,如何把该文件名与当前选择的后缀(如: RTF,TXT,DOC等)连接成一个完整的文件名?
bb="(*.rtf)|*.rtf|(*.txt)|*.txt|(*.doc)|*.doc|";//這是設置可選擇類型
CFileDialog dlg(FALSE, "rtf", NULL, OFN_OVERWRITEPROMPT,bb);
//dlg裡面的rtf是設置默認擴展名的
dlg.DoModal()選擇後.自動會和你當前所選擇的類型結合.並且成為你名稱的后綴.
if(IDCancle==dlg.DoModal()) return;
CString aaa;
aaa=dlg.GetPathName();
aaa.MakeLower();
if(csTemp.Right(4)!=".doc")//這裡判斷類型