* * *

Author Topic: TZipper usage problem  (Read 2342 times)

vix

  • New member
  • *
  • Posts: 22
TZipper usage problem
« on: August 26, 2010, 11:59:36 pm »
Hello

I try to create program which will make a zip file of documents from disk. I try to use a TZipper. "I try" 'cause only one example of usage i found. It's that code:
Code: [Select]
FZipper.FileName:=ParamStr(1);
 For I:=2 to ParamCount do
   begin
   F:=TFileStream.Create(ParamStr(i),fmOpenRead);
   FZipper.Entries.AddFileEntry(F,ParamStr(i));
   end;
 FZipper.ZipAllFiles;
 For I:=0 to FZipper.Entries.Count-1 do
   FZipper.Entries[I].Stream.Free;
from http://wiki.lazarus.freepascal.org/paszlib .

So i put on a form a memo and put in a lines paths to documents. Then i modify the code to
Code: [Select]
  FZipper.FileName:=memo1.Lines[0];
  For I:=1 to memo1.Lines.Count-1 do
    begin
    F:=TFileStream.Create(memo1.Lines[i],fmOpenRead);
    FZipper.Entries.AddFileEntry(F,memo1.Lines[i]);
    end;
  FZipper.ZipAllFiles;
  For I:=0 to FZipper.Entries.Count-1 do
    FZipper.Entries[I].Stream.Free;
TZipper FileName property is a string type. Each line of memo is also a string. So it should work in theory. But.. it does not work. There is a External SIGSEGV error in the beginning, in a line "FZipper.FileName:=memo1.Lines[0];" So i wondering what i did wrong?

Do you have some ideas how to zip files? or you know some good docs for TZipper?

Thank you in advance :)

Best regards :)
Tarzan no understand what mean syntax error...
..look out for my english..

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1671
Re: TZipper usage problem
« Reply #1 on: August 27, 2010, 01:09:18 am »
Erm, maybe a stupid question, but did you create the FZipper?

FZipper:=TZipper.Create;


captain jaster

  • Sr. Member
  • ****
  • Posts: 386
Re: TZipper usage problem
« Reply #2 on: August 27, 2010, 01:32:37 am »
Erm, maybe a stupid question, but did you create the FZipper?

FZipper:=TZipper.Create;


Yeah...
For future references, Know that all classes use a constructor :p. Without it. Your code is kapoot
-Captain Jaster

vix

  • New member
  • *
  • Posts: 22
Re: TZipper usage problem
« Reply #3 on: August 27, 2010, 09:52:23 pm »
Thank you :)

I used a Create method, but in a wrong way. My mistake!

thanks for help :)

Best regards
Tarzan no understand what mean syntax error...
..look out for my english..

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads