您的位置:首页 > 其它

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

2017-11-28 16:24 441 查看
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.
object Form2: TForm2Left = 0Top = 0Caption = #33258#21160#25171#21253#22120ClientHeight = 421ClientWidth = 691Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'Tahoma'Font.Style = []OldCreateOrder = FalseOnCreate = FormCreatePixelsPerInch = 96TextHeight = 13object LabeledEdit1: TLabeledEditLeft = 40Top = 48Width = 561Height = 21EditLabel.Width = 60EditLabel.Height = 13EditLabel.Caption = #25991#20214#22841#36335#24452TabOrder = 0endobject LabeledEdit2: TLabeledEditLeft = 40Top = 96Width = 121Height = 21EditLabel.Width = 60EditLabel.Height = 13EditLabel.Caption = #25991#20214#22841#25513#30721TabOrder = 1endobject LabeledEdit3: TLabeledEditLeft = 40Top = 144Width = 561Height = 21EditLabel.Width = 48EditLabel.Height = 13EditLabel.Caption = #36755#20986#36335#24452TabOrder = 2endobject Button1: TButtonLeft = 40Top = 192Width = 121Height = 65Caption = #24320#22987'(&S)'TabOrder = 3OnClick = Button1Clickendend
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐