![]() |
|
تجميع ملفات في ملف واحد - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15) +--- الموضوع : تجميع ملفات في ملف واحد (/showthread.php?tid=3495) |
تجميع ملفات في ملف واحد - لؤي - 10-10-2011 سلام الله عليكم لدي حلقة بحث تتكون من متغيرين اليوم و المسلك كود : begin
x:=0;
fichierTmp.Clear ;
if FileExists(ListBox1.Items.Strings[x]+ 'File.' +
IntToHex(StrToInt(FormatDateTime('m',cptDate)),00)+
FormatDateTime('dd',cptDate)) then
begin
for i:= 0 to ListBox1.Count -1 do {fixer la date est varié le chemin}
begin
fichierTmp.Clear;
fichierTmp.LoadFromFile( ListBox1.Items.Strings[i]+ 'File.' +
IntToHex(StrToInt(FormatDateTime('m',cptDate)),00)+
FormatDateTime('dd',cptDate)) ;
fichierFinal.AddStrings( fichierTmp ) ;
end; i:=i+1;
end;// else ShowMessage('no existe');
cptDate := cptDate + 1;
x:=x+1;
end ;لما لا أجد في الشرط الملف المقصود if FileExists(ListBox1.Items.Strings[x]+ 'File.' + IntToHex(StrToInt(FormatDateTime('m',cptDate)),00)+FormatDateTime('dd',cptDate)) فأنا مطظر لتخطي كامل الحلقة التي تليها و بالتالي أفقد ملفات داخل هذه الحلقة. كيف لي أن أتفادى هذا المشكل الحلقة المقصودة هي : كود : for i:= 0 to ListBox1.Count -1 do
begin
fichierTmp.Clear;
fichierTmp.LoadFromFile( ListBox1.Items.Strings[i]+ 'File.' +
IntToHex(StrToInt(FormatDateTime('m',cptDate)),00)+
FormatDateTime('dd',cptDate)) ;
fichierFinal.AddStrings( fichierTmp ) ;
end; i:=i+1;تجميع ملفات في ملف واحد - Lam.Abdeldjalil - 10-10-2011 وعليكم السلام ورحمة الله كود : for[COLOR=Green] i:= 0[/COLOR] [COLOR=Red]to[/COLOR][COLOR=Green] ListBox1.Count -1[/COLOR] do
..
..
[COLOR=Blue]// i:=i+1;[/COLOR]تجميع ملفات في ملف واحد - لؤي - 11-10-2011 سلام الله عليكم لم أفهم قصدك أخي عبد الجليل المتغير I هو نفسه المتغير x في حالتي لاحظ معي : PHP كود : if FileExists(ListBox1.Items.Strings[x] PHP كود : for i:= 1 to ListBox1.Count -1 do تجميع ملفات في ملف واحد - محمد عبد العزيز - 11-10-2011 السلام عليكم ورحمة الله الخطأ هنا إقتباس :fixer la date est varié le cheminالمفروص يكون العكس le chemin est fixe varié la date هنا كود : if FileExists([color=Red]ListBox1.Items.Strings[x][/color]+ 'File.' + .....كود : fichierTmp.LoadFromFile( [color=#ff0000]ListBox1.Items.Strings[i][/color]+....تجميع ملفات في ملف واحد - لؤي - 11-10-2011 [FONT="Comic Sans MS"]هذا الكود إشتغل معي شكرا لك اخي كود : var cptDate : TDate ;x,i:Integer;
fichierTmp, fichierFinal : TStringList ;
begin
//initialisation du compteur de Date (DateTimePicker1)
cptDate := DateTimePicker1.DateTime;
//Création des TStringList
fichierTmp := TStringList.Create ;
fichierFinal := TStringList.Create;
//Boucle tant que l'on a pas atteint la Date supérieure (DateTimePicker2)
while cptDate < DateTimePicker2.DateTime do
begin
fichierTmp.Clear ; // on vide le contenu
for i:= 0 to ListBox1.Count -1 do
begin
fichierTmp.Clear;
if fileExists(ListBox1.Items.Strings[i]+ ‘File.'
+ IntToHex(StrToInt(FormatDateTime('m',cptDate)),00)+FormatDateTime('dd',cptDate)) then
Begin {fixer la date est varié le chemin}
fichierTmp.LoadFromFile( ListBox1.Items.Strings[i]+ ‘File.'
+ IntToHex(StrToInt(FormatDateTime('m',cptDate)),00)+FormatDateTime('dd',cptDate)) ; //Chargement du fichier
fichierFinal.AddStrings( fichierTmp ) ; // Ajout du fichier chargé au fichier final
end;
end ;
cptDate := cptDate + 1; //Incrémentation de la date
end ;
fichierFinal.SaveToFile( 'C:\fichierFinal.txt' ) ; //Sauvegarde du fichier Final
//Libération des ressources
fichierTmp.Free;
fichierFinal.Free;
end; |