hi,
as i already discussed in my last thread that my exe is not working for large number of files but it is doing really well with fewer files.
today i took a screenshot and got the following error...
here is my code..i am even trying to put delay in it..kindly suggest ways to add delay fuction beacuse it is giving an error evry time i use it and please look into it if anyother solution or change is required...
#include<fstream>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<time.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>
using namespace std;
int main()
{ int fcount=0,capcount=0;
system("ERASE filelist.txt");
//ofstream log;
//log.open("activitylog.txt",ios::out);
system("dir>filelist.txt");
char c,c1,c2,c3,c4,c5,c6;
char PLO[16],fn1[500],fn2[500],cmd[50],SERIAL[20],inffile[300];
c1=c2=c3=c4=c5=c6=0;
char str[30];
ifstream fl;
fl.open("filelist.txt",ios::in);
if(!fl)
{
cout<<"The file filelist.txt not found in this folder"<<endl<<endl;
//log <<"The file filelist.txt not found in this folder"<<endl<<endl;
}
while(fl)
{
fl>>str;
if(str[strlen(str)-1]=='p'&&str[strlen(str)-2]=='a'&&str[strlen(str)-3]=='c'&&str[strlen(str)-4]=='.')
{
capcount++;
int flag=1,finf=0,fcap=0;
ifstream fin,gin;
ofstream f1,f2;
fin.open(str,ios::in);
if(!fin)
{
cout<<"Cannot open file "<<str<<endl;
//log<<"Cannot open file "<<str<<endl;
}
c1=c2=c3=c4=c5=c6=0;
while(fin&&flag)
{
c6=c5;
c5=c4;
c4=c3;
c3=c2;
c2=c1;
fin.get(c1);
if((c6=='<')&&(c5=='O')&&(c4=='R')&&(c3=='D')&&(c2=='E')&&(c1=='R'))
flag=0;
}
int count=0;
fin.get(c);
c='1';
while(c!='<')
{
fin.get(c);
if(c!='<')
PLO[count++]=c;
};
PLO[count]='\0';
fin.close();
cout<<"The PLO number found in file "<<str<<" is :";
//log<<"The PLO number found in file "<<str<<" is :";
for(int i=0;i<count;i++)
{
cout<<PLO[i];
//log<<PLO[i];
}
cout<<endl;
//log<<endl;
c1=c2=c3=c4=c5=c6=0;
flag=1;
fin.open(str,ios::in);
if(!fin)
{
cout<<"Cannot open file "<<str<<endl;
//log<<"Cannot open file "<<str<<endl;
}
while(fin&&flag)
{
c4=c3;
c3=c2;
c2=c1;
fin.get(c1);
if((c4=='<')&&(c3=='S')&&(c2=='N')&&(c1=='>'))
flag=0;
}
count=0;
c='1';
while(c!='<')
{
fin.get(c);
if(c!='<')
SERIAL[count++]=c;
};
SERIAL[count]='\0';
cout<<"The serial number found in file "<<str<<" is :";
//log<<"The serial number found in file "<<str<<" is :";
for(int i=0;i<count;i++)
{
cout<<SERIAL[i];
//log<<SERIAL[i];
}
cout<<endl;
//log<<endl;
fin.close();
sprintf(inffile,"%s.inf",SERIAL);
sprintf(cmd,"mkdir %s",PLO);
system(cmd);
sprintf(fn2,"%s/%s",PLO,inffile);
sprintf(fn1,"%s/%s",PLO,str);
gin.open(inffile,ios::in);
if(!gin)
{
cout<<"couldn't open file "<<inffile<<" corresponding to file "<<str<<endl;
//log<<"couldn't open file "<<inffile<<" corresponding to file "<<str<<endl;
}
else
{
f2.open(fn2,ios::out);
while(gin)
{
gin.get(c);
f2.put(c);
}
gin.close();
f2.close();
fcount++;
sprintf(cmd,"ERASE %s",inffile);
system(cmd);
cout<<"The file "<<inffile<<" successfully deleted "<<endl;
//log<<"The file "<<inffile<<" successfully deleted "<<endl;
finf=1;
}
fin.open(str,ios::in);
if(!fin)
{
cout<<"Couldn't open file "<<str<<endl;
//log<<"Couldn't open file "<<str<<endl;
}
else
{
f1.open(fn1,ios::out);
while(fin)
{
fin.get(c);
f1.put(c);
}
fin.close();
f1.close();
fcount++;
sprintf(cmd,"ERASE %s",str);
system(cmd);
cout<<"The file "<<str<<" successfully deleted "<<endl;
//log<<"The file "<<str<<" successfully deleted "<<endl;
fcap=1;
}
if(fcap&&finf)
{
cout<<"Folder "<<PLO<<" created successfully with files "<<str<<" and "<<inffile<<endl<<endl;
//log<<"Folder "<<PLO<<" created successfully with files "<<str<<" and "<<inffile<<endl<<endl;
}
if(!fcap)
{
cout<<"\aCouldn't copy file "<<str<<" to "<<PLO<<endl;
//log<<"Couldn't copy file "<<str<<" to "<<PLO<<endl;
}
if(!finf)
{
cout<<"\aCouldn't copy file "<<inffile<<" to "<<PLO<<endl;
//log<<"Couldn't copy file "<<inffile<<" to "<<PLO<<endl;
}
cout<<endl<<endl;
//log<<endl<<endl;
}
}
fl.close();
if(capcount==0)
cout<<"No cap file found"<<endl;
cout<<fcount<<" files copied "<<endl;
//log<<fcount<<" files copied "<<endl;
//cout<<"Now copying the activity log in a file with the current date and time"<<endl;
//log.close();
//char n1[]="activitylog.txt";
//char n2[]="log_%date:/=-%[%time::=-%].txt";
//sprintf(cmd,"copy %s %s ",n1,n2);
//cmd[5]=cmd[21]=cmd[23]=cmd[54]='"';
//system(cmd);
//system("ERASE activitylog.txt");
}