Forum > General

Compress all files in the local directory without the problem of the local direc


I have a folder "temp" with 4 files in it. temp\1 , temp\2\324 ,temp\3,temp\4\N;

I want to compress all files (including folders) in the temp folder, but the forum code I refer to will compress the temp folder together. I only want to compress the 1;2\324;3;4\N files into a compressed package separately, not together with the temp folder. That is to say, you can only see 4 files when you open the compressed package, instead of seeing the temp folder, and you can see 4 files when you enter.

Network translation, I don't know if I understand, thank you first.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  DataBack_upFileName: string;  AZipper: TZipper;  szPathEntry: string;  i: integer;  ZEntries: TZipFileEntries;  TheFileList: TStringList;  RelativeDirectory: string;begin   SaveDialog1.Filter := ' zip压缩文件(*.zip)|*.zip';  SaveDialog1.Title := '选择zip压缩路径和文件名';    if SaveDialog1.Execute then   begin    if SaveDialog1.FileName='' then     begin     exit;     end    else     begin       try       AZipper := TZipper.Create;      try        try         RelativeDirectory:=ExtractFilePath(ParamStr(0)) + 'temp\';         AZipper.Clear;        ZEntries := TZipFileEntries.Create(TZipFileEntry);         If DirPathExists(RelativeDirectory) then        begin           i:=RPos(PathDelim,ChompPathDelim(RelativeDirectory));          szPathEntry:=LeftStr(RelativeDirectory,i);           TheFileList:=TstringList.Create;           try             FindAllFiles(TheFileList, RelativeDirectory);             for i:=0 to TheFileList.Count -1 do              begin               ZEntries.AddFileEntry(TheFileList[i],CreateRelativePath(TheFileList[i],szPathEntry));              end;           finally            if Assigned(TheFileList) then             FreeAndNil(TheFileList);          //TheFileList.Free;        end;       end;       if (ZEntries.Count > 0) then         AZipper.ZipFiles(ZEntries);      except        On E: EZipError do          E.CreateFmt('无法创建zip文件%原因: %s', [LineEnding, E.Message])      end;   finally    if Assigned(ZEntries) then    FreeAndNil(ZEntries);     if Assigned(AZipper) then     FreeAndNil(AZipper);  end;       Application.MessageBox('数据压缩成功!!',      '提示!',  mb_OK);     except      Application.MessageBox('数据压缩失败!!',      '错误提示!', MB_ICONERROR + mb_OK);    end;    end;   end; end;                                                       

It's solved with this method!,39475.msg271157.html#msg271157


[0] Message Index

Go to full version