Solved

Compress archives if a delphi memo

Posted on 2010-09-06
7
558 Views
Last Modified: 2013-11-23
I would like to Capture the files that are in a particular folder and list all files in MEMO.
And where will have a label that counted the number of files listed

After listing these archives  a  memo, compress files into one so.
Format. Kom

Note: The file folder of this format. Moon

Could you help me with this?
What I really need to compress and share
0
Comment
Question by:nkilla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 33613167
you are asking a question which is very cryptic

to list files: use TSearchRec and FindFirst, FindNext
lots of links here:
http://www.torry.net/search.htm

to compress, you need to think about the component you need to use
http://www.torry.net/pages.php?s=99
http://www.torry.net/pages.php?id=302
http://www.torry.net/pages.php?id=303

Moon ???
0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 33627842
This is how I do it; Hacked up my code to give you an example;
uses zlibex;
///////////////////////////////////////////////////////////////////
procedure TForm1.ClientDataset1AfterScroll(DataSet: TDataSet);
begin
  if DataSet.IsEmpty then exit;
  try
    if (not clientdataset1Field1.IsNull) and
      (clientdataset1Field1.AsString <> '') then
    Memo.Text :=  zlibex.ZDeCompressStr( clientdataset1Field1.AsString)
    else SysPrepStrings.Text :=  '';
  except
    on E:Exception do
    begin
    end;
  end;
end;
///////////////////////////////////////////////////////////////////
procedure Form1.ClientDataset1GetText(Sender: TField;
                                       var Text: string; DisplayText: Boolean);
begin
  if not (Sender is TMemoField) then exit;
  if TMemoField(Sender).AsString = '' then exit;
  try
    if (not clientdataset1Field1.IsNull) and
      (clientdataset1Field1.AsString <> '') then
    Text :=  zlibex.ZDeCompressStr(clientdataset1Field1.AsString)
    else Text :=  '';
  except
    on E:Exception do
    begin
    end;
  end;
  Memo1.Text := Text;
end;

Open in new window

ZLIBEX.PAS
0
 
LVL 5

Accepted Solution

by:
briangochnauer earned 500 total points
ID: 33627969
or maybe you meant something like this; except from a piece I wrote; *very simple*.
uses zippit.pas // attached file;
/////////////////////////////////////////////////////////
procedure ZipLogFiles(FilesOnPath:String; ZipFilename:String);
var  Zip: TZippit;
begin
  Zip := TZippit.Create;
  try
    Zip.AddFiles(FilesOnPath);// like 'c:\windows\system32\*.*');
    Zip.AddFiles('c:\windows\system32\PNPDevices.xml');
    Zip.AddFiles(LogFileDir+'\*.*');
    Zip.SaveToFile(ZipFilename);  finally
    Zip.Free;
  end;
end;
/////////////////////////////////////////////////////////
procedure ZipLogFiles(FilesOnPath:String; ZipFilename:String);
var  Zip: TZippit;
begin
  Zip := TZippit.Create;
  try
    Zip.AddFiles(FilesOnPath);// like 'c:\windows\system32\*.*');
    Zip.AddFiles('c:\windows\system32\PNPDevices.xml');
    Zip.AddFiles(LogFileDir+'\*.*');
    Zip.SaveToFile(ZipFilename);  finally
    Zip.Free;
  end;
end;

Open in new window

Zippit-0.0.1.zip
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:nkilla
ID: 33632821
I do not understand very well
Well my code this way
Now I need to compress all files in the folder.
All files will listed on memo , and i compress this
Which are 258 files. Moon in python, which weighs 5 megs or so.

So I want to compress it all into a file with edited.kom 824kbytes
procedure TForm1.Button1Click(Sender: TObject);
begin
  tamanhoTotal := 0;
  memLista.Lines.Clear;
  ListarArquivos(edtDiretorio.Text, chkSub.Checked);
  Edit1.Text := IntToStr( tamanhoTotal );
end;

procedure TForm1.ListarArquivos(Diretorio: string; Sub:Boolean);
var
  F: TSearchRec;
  Ret: Integer;
  TempNome: string;
begin
  Ret := FindFirst(Diretorio+'\*.*', faAnyFile, F);
  try
    while Ret = 0 do
      begin
        if TemAtributo(F.Attr, faDirectory) then
          begin
            if (F.Name <> '.') And (F.Name <> '..') then
              if Sub = True then
                begin
                  TempNome := Diretorio+'\' + F.Name;
                  ListarArquivos(TempNome, True);
                end;
          end
        else
          begin
            memLista.Lines.Add(Diretorio+'\'+F.Name);
            tamanhoArquivo( Diretorio+'\'+F.Name );
          end;
        //
        Ret := FindNext(F);
      end;
  finally
    begin
      FindClose(F);
    end;
  end;
end;

function TForm1.TemAtributo(Attr, Val: Integer): Boolean;
begin
  Result := Attr and Val = Val;
end;

procedure TForm1.tamanhoArquivo(Arq: String);
var
  SR: TSearchRec;
  I: integer;
begin
  I := FindFirst(arq, faArchive, SR);
  try
    if I = 0 then
      tamanhoTotal := tamanhoTotal + ( SR.Size );
  finally
    FindClose(SR);
  end;
end;


end.

Open in new window

0
 
LVL 5

Expert Comment

by:briangochnauer
ID: 33637477
I have seen no definition of ?moon? or what a kom file is, but maybe something like;

memLista.Lines.SaveToFile('c:\text.txt');
then winexec a python script to read the text file and compress into a .kom file.

else I think your in the wrong forum zone.
0
 

Author Comment

by:nkilla
ID: 33749064
Dont work =/
Is a complex encrypt
0
 

Author Closing Comment

by:nkilla
ID: 33779290
This solution resolved my problem thanks for helping experts
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month7 days, 18 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question