现在的位置: 首页 > 综合 > 正文

浏览——用户自定义路径

2014年01月19日 ⁄ 综合 ⁄ 共 1130字 ⁄ 字号 评论关闭
//用户自定义路径
//
void CPMAgentManageDlg::OnCheckSavefile() 
{
 // TODO: Add your control notification handler code here
 CString   str,m_Path;     
 BROWSEINFO   bi;     
 char   name[MAX_PATH];      
 ZeroMemory(&bi,sizeof(BROWSEINFO));     
 bi.hwndOwner=GetSafeHwnd();       
 bi.pszDisplayName=name;       
 bi.lpszTitle="选择日志文件要保存的文件夹:";    
 LPITEMIDLIST   idl=SHBrowseForFolder(&bi);      
 if(idl==NULL) return;       
 SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));     
 str.ReleaseBuffer();       
 m_Path=str;       
 UpdateData(true);
 if(str.GetAt(str.GetLength()-1)!='\\')   m_Path+="\\"; 
/* m_FilePath=m_Path;*/  //m_Path就是用户选择的要保存的路径
    UpdateData(false);  
}

 

方法二:

char tmp[1024];
CTime curTime = CTime::GetCurrentTime();
sprintf(tmp,"log_%4d%02d%02d.log",curTime.GetYear(),curTime.GetMonth(),curTime.GetDay());
string sPath = tmp;
CFileDialog dlg( FALSE, _T( "txt" ), _T(tmp), OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY, _T( "log文件|*.log|所有文件|*||" ) );
dlg.m_ofn.lpstrTitle=_T("日志信息保存为log文件");
if ( dlg.DoModal() == IDOK )
{
	bFile = TRUE;
	folderName = dlg.GetPathName(); //用户自定义的路径
	string sSour = lpTempLogFilePath;
	string sDest = folderName;
	FileCopyTo(sSour,sDest,TRUE);
}
	else
	{
		m_cFileButton.SetCheck(FALSE);
		return;
	}

 

抱歉!评论已关闭.