一个文件夹循环问题
我在D盘有一个file文件夹,里面有0、1、2、3、4 五个子文件夹。每个子文件夹下又有10个文件。每个文件512个字节。其中0文件夹里有0.dat、1.dat、2.dat…9.dat共十个文件,1文件夹里有10.dat…19.dat 十个文件,其他文件夹以此类推。现想将这五个文件夹下共50个文件连接成一个文件,放在D:\file.dat中。编程如下,可是只能将0文件夹下的文件连接成file.dat文件,for循环并没有循环。为什么。
int i=0;
int m=0;
int t=10;
CString str1("D:\\file\\");
CString str2;
CString str3;
CString text;
CFile filetwo("d:\\file.dat",CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate);
for(m=0;m<5;m++)
{
str2.Format(("%d"),m); //把m变为字符,放入str2中
while(i<t)
{
str3.Format(("%d"),i); //把i变为字符,放入str3中
text=str1+str2+"\\"+str3+".dat"; //得到路径
unsigned char p[512];
CFile fileone;
fileone.Open(text,CFile::modeRead,NULL);
fileone.Read(p,512);
filetwo.Write(p,512);
fileone.Close();
i=i+1;
}
i=i+10;
t=t+10;
}
}