阅读背景:

找到目录下的文件夹 并且进行压缩,然后再生成压缩文件到指定目录

来源:互联网 
unit uMainForm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ioutils, Types, zip, Vcl.StdCtrls,
  Vcl.ExtCtrls;

type
  TForm2 = class(TForm)
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
var
  dfs : TStringDynArray;
  strDirectory : string;
  strFile : string;
begin
  dfs := TDirectory.GetDirectories(self.LabeledEdit1.Text, self.LabeledEdit2.Text);
  for strDirectory in dfs do
  begin
    strFile := (TPath.GetFileName(strDirectory));

    TZipFile.ZipDirectoryContents(self.LabeledEdit3.Text + '\' + strFile + '.zip', strDirectory);
  end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  self.LabeledEdit1.Text := TPath.GetFullPath('.\');
  self.LabeledEdit2.Text := '*';
  self.LabeledEdit3.Text := TPath.GetFullPath('..\');
end;

end.
unit uMainForm;

interface

uses
  Winapi.Windo



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: