16,472
社区成员
发帖
与我相关
我的任务
分享
CString CPropPage4::SelectSaveFilePath()
{
CString strTime = CTime::GetCurrentTime().Format("%n年%m月%d日%a %H时%M分%S秒");
char szFile[260];
strncpy(szFile,(LPCTSTR)strTime,sizeof(szFile));// buffer for filename
OPENFILENAME ofn;
memset(szFile,0,sizeof(szFile));
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = m_hWnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = szFile;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = ".\\voice\\";
// ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST|OFN_OVERWRITEPROMPT;
ofn.lpstrFilter = "WAVE file(*.WAV)\0*.WAV\0All file\0*.*\0";
ofn.lpstrDefExt = ".wav";
if(::GetSaveFileName(&ofn))
{
CString strDestPath = szFile;
return strDestPath;
}
return "";
}
CFile file;
file.Open("默认路径名", CFile::ModeCreate | CFile::ModeReadWrite);
file.Write(..);
file.Close();