delphi4arab منتديات دلفي للعرب
حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar (/showthread.php?tid=3857)



حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar - SamirAloui - 09-02-2012

السلام عليكم


شاهدة في أحد البرامج طريقة رائعة في حفظ نسخة من قاعدة البيانات على شكل ملف مضغوط
كأرشف مثلاً و إستعادتها لما يريد المستخدم هذا
أضن أنه يوجد مكون يلبي هذا الغرض بحثت ولم أجد المكون المتوافق مع نسخة Delphi XE


حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar - لؤي - 09-02-2012

و عليكم السلام
إبحث جيدا تجد مكونات تقوم بالضغط هذه وظيفة تقوم بضغط الملفات :
كود :
uses [color=Red]ZLib[/color] procedure CompressFiles(Files : TStrings; const Filename : String); var infile, outfile, tmpFile : TFileStream; compr : TCompressionStream; i,l : Integer; s : String; begin if Files.Count > 0 then begin outFile := TFileStream.Create(Filename,fmCreate); try { the number of files } l := Files.Count; outfile.Write(l,SizeOf(l)); for i := 0 to Files.Count-1 do begin infile := TFileStream.Create(Files[i],fmOpenRead); try { the original filename } s := ExtractFilename(Files[i]); l := Length(s); outfile.Write(l,SizeOf(l)); outfile.Write(s[1],l); { the original filesize } l := infile.Size; outfile.Write(l,SizeOf(l)); { compress and store the file temporary} tmpFile := TFileStream.Create('tmp',fmCreate); compr := TCompressionStream.Create(clMax,tmpfile); try compr.CopyFrom(infile,l); finally compr.Free; tmpFile.Free; end; { append the compressed file to the destination file } tmpFile := TFileStream.Create('tmp',fmOpenRead); try outfile.CopyFrom(tmpFile,0); finally tmpFile.Free; end; finally infile.Free; end; end; finally outfile.Free; end; DeleteFile('tmp'); end; end;
لفك الضغط :
كود :
procedure DecompressFiles(const Filename, DestDirectory : String); var dest,s : String; decompr : TDecompressionStream; infile, outfile : TFilestream; i,l,c : Integer; begin // IncludeTrailingPathDelimiter (D6/D7 only) dest := IncludeTrailingPathDelimiter(DestDirectory); infile := TFileStream.Create(Filename,fmOpenRead); try { number of files } infile.Read(c,SizeOf(c)); for i := 1 to c do begin { read filename } infile.Read(l,SizeOf(l)); SetLength(s,l); infile.Read(s[1],l); { read filesize } infile.Read(l,SizeOf(l)); { decompress the files and store it } s := dest+s; //include the path outfile := TFileStream.Create(s,fmCreate); decompr := TDecompressionStream.Create(infile); try outfile.CopyFrom(decompr,l); finally outfile.Free; decompr.Free; end; end; finally infile.Free; end; end;

للتنفيذ:

PHP كود :
CompressFiles(ListBox1.Items,'c:\Folder.myzip'); 



حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar - SamirAloui - 10-02-2012

وجدت مكون VCLZip Pro متخصص في تحزيم ملفات قواعد البيانات مثلاً Access على شكل ملف zip
و يقوم تلقائياً بتسمية الملف بتاريخ اليوم و يتيح لك إستعادة ملف قاعدة البيانات متى أردت
و هذا ما أبحث عنه بالضبط لكن المشكلة أنه متوافق مع Delphi 7 و Delphi 6 و Delphi 5


حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar - nasser26 - 11-02-2012

أخي لا داعي لكل هذا اليك الكود
كود :
application.Terminate; ShellExecute(Handle,'','WinRar','a NOM.rar *.* ',nil, SW_NORMAL)

قم بتغيير بياناتك فقط اسم قاعدة البيانات و نوع الملفات المراد وضعها في ارشيف


حفظ نسخة من قاعدة البيانات في ملف Zip أو Rar - Bachirsoft - 03-04-2014

هل يمكن التوضيح أكثر لإنني وجدت كود ولم استطع التغيير عليه او حتي فهمه
وخاصة الفقرة الأخيرة

var
archiver : TZipForge;

begin
// Create an instance of the TZipForge class
archiver := TZipForge.Create(nil);
try
with archiver do
begin
// Set the name of the archive file we want to create
FileName := 'C:\test.zip';
// Because we create a new archive,
// we set Mode to fmCreate
OpenArchive(fmCreate);
// Set base (default) directory for all archive operations
BaseDir := 'C:\';
// Add file C:\test.txt the archive; wildcards can be used as well
AddFiles('c:\test.txt');
CloseArchive();
end;
except
on E: Exception do
begin
Writeln('Exception: ', E.Message);
// Wait for the key to be pressed
Readln;
end;
end;