void baocundlg::OnOK()
{
UpdateData();
theApp.n=m_d;
CopyFile("d:\\1.txt", "d:\\"+theApp.n+".txt", 0);
CStdioFile ff;
CFileException mExcept;
if(ff.Open("d:\\jilu.txt",CFile::modeCreate ¦CFile::modeNoTruncate ¦CFile::modeWrite,&mExcept))
ff.SeekToEnd();
ff.WriteString(theApp.n);
ff.WriteString("\n");
ff.Close();
}
{
UpdateData();
theApp.n=m_d;
CopyFile("d:\\1.txt", "d:\\"+theApp.n+".txt", 0);
CStdioFile ff;
CFileException mExcept;
if(ff.Open("d:\\jilu.txt",CFile::modeCreate ¦CFile::modeNoTruncate ¦CFile::modeWrite,&mExcept))
ff.SeekToEnd();
ff.WriteString(theApp.n);
ff.WriteString("\n");
ff.Close();
}
if (filefind.FindFile("d:\\jilu.txt"))//file exist
{
}
printf ("file exists");
else
printf ("file not exists");
1、BOOL PathFileExists(LPCTSTR lpszPath); SHELL API
2、DWORD GetFileAttributes(LPCTSTR lpFileName); API
我那些文件名都保存在jilu.txt中.
能在说详细点吗?
CStdioFile stdfile;
stdfile.Open( "d:\\jilu.txt", CFile::modeRead | CFile::typeText ) )
BOOL bLine = stdfile.ReadString(strTitle);
BOOL bFind = FALSE;
while (bLine)
{
if(strTitle == theApp.n)
bFind = TRUE;
}
if(bFind)
{
文件名已存在
}
if(ff.Open("d:\\jilu.txt",CFile::modeCreate ¦CFile::modeNoTruncate ¦CFile::modeWrite,&mExcept))
ff.SeekToEnd();
ff.WriteString(theApp.n);
ff.WriteString("\n");
ff.Close();
}之前;
E:\zxn\diefa\diebanbaocundlg.cpp(62) : error C2059: syntax error : ')'
E:\zxn\diefa\diebanbaocundlg.cpp(63) : error C2146: syntax error : missing ';' before identifier 'BOOL'
E:\zxn\diefa\diebanbaocundlg.cpp(63) : error C2146: syntax error : missing ';' before identifier 'bLine'
E:\zxn\diefa\diebanbaocundlg.cpp(63) : error C2275: 'BOOL' : illegal use of this type as an expression
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\windef.h(142) : see declaration of 'BOOL'
E:\zxn\diefa\diebanbaocundlg.cpp(63) : error C2065: 'bLine' : undeclared identifier
E:\zxn\diefa\diebanbaocundlg.cpp(63) : error C2065: 'strTitle' : undeclared identifier
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xce'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xc4'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xbc'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xfe'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xc3'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xfb'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xd2'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xd1'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xb4'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xe6'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xd4'
E:\zxn\diefa\diebanbaocundlg.cpp(72) : error C2018: unknown character '0xda'
CStdioFile stdfile;
stdfile.Open( "d:\\jilu.txt", CFile::modeRead | CFile::typeText ) ) ;
BOOL bLine = stdfile.ReadString(strTitle);
BOOL bFind = FALSE;
while (bLine)
{
if(strTitle == theApp.n)
bFind = TRUE;
}
if(bFind)
{
AfxMessageBox("error");
return;
}
CStdioFile stdfile;
stdfile.Open( "d:\\jilu.txt", CFile::modeRead | CFile::typeText ) ) ;
CString strTitle;
BOOL bLine = stdfile.ReadString(strTitle);
BOOL bFind = FALSE;
while (bLine)
{
if(strTitle == theApp.n)
{
bFind = TRUE;
break;
}
bLine = stdfile.ReadString(strTitle);
}
if(bFind)
{
AfxMessageBox("error");
return;
}
你那个我没看明白,不好意思,你回答我好几个帖子了,谢谢你.