关于串口通信
在串口通信的接收使用了\r\n进行换行,但是在保存的时候怎么把\r\n消除掉?
void CCommWizardDlg::OnSavedata()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
int nLength;
nLength=m_strCurPath.GetLength();
for(int nCount=0;nCount<nLength;nCount++)
{
if(m_strCurPath.GetAt(nCount)=='\\')
CreateDirectory(m_strCurPath.Left(nCount+1),NULL);
}
CreateDirectory(m_strCurPath,NULL);
CFile m_nFile;
LPCSTR lpszPath=m_strCurPath;
SetCurrentDirectory(lpszPath);
char buf[30];
for(int j=0;j<100;j++)
{
sprintf(buf,"Rec%02d.txt",j);
}
if(!m_nFile.Open(buf,CFile::modeCreate|CFile::modeWrite))
{
AfxMessageBox("创建记录文件失败");
return;
}
CTime t=CTime::GetCurrentTime();//获取系统日期
CString str=t.Format("%Y年%m月%d日%H时%M分%S秒\r\n");
m_nFile.Write((LPCSTR)str,str.GetLength());
m_nFile.Write((LPCSTR)m_strReceive,m_strReceive.GetLength());
m_nFile.Flush();
m_nFile.Close();
}
void CCommWizardDlg::OnDirbrowser()
{
// TODO: Add your control notification handler code here
static char displayname[MAX_PATH];
static char path[MAX_PATH];
LPITEMIDLIST pidlBrowse;
BROWSEINFO bi;
bi.hwndOwner=this->m_hWnd;
bi.pidlRoot=NULL;
bi.pszDisplayName=displayname;
bi.lpszTitle=("请选择要保存接收数据的文件夹");
bi.ulFlags=BIF_EDITBOX;
bi.lpfn=NULL;
pidlBrowse=SHBrowseForFolder(&bi);
if(pidlBrowse!=NULL)
{
SHGetPathFromIDList(pidlBrowse,path);
}
CString str=path;
if(str.IsEmpty())return;
m_strCurPath=str;
UpdateData(false);
}