浏览——用户自定义路径

//用户自定义路径
//
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;
	}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值