FSTREAM读取目录下的所有文件 出错
/* 为什么不能循环读p目录下所有TXT文件 读到第2个TXT文件就错了 答案详细一点谢谢 */
_chdir(p.c_str());
if((file=_findfirst("*.*", &find)) == -1)
{
MessageBox("empty");
return 1;
}
while(_findnext(file, &find)==0)
{
if (strcmp(find.name, "..") == 0)
{
continue;
}
_chdir(p.c_str());
fio.open(find.name, ios::binary);
if (!fio)
{
MessageBox("open file error");
int i = GetLastError();
}
size_t index = 2;
fio.seekg(index, ios::beg); ////
//while (!fio.eof())
wchar_t wc=0;
while (fio.read((char *)(&wc), 2) != NULL)
{
index = fio.eof();
{
if(wc != 0)
{
wstrLine.append(1, wc);
strLineAnsi = ws2s(wstrLine);
}
}
}
fio.close(); //测试
}
_findclose(file);