UnpackFile(Path: String);
UnpackFile(Path: String);
Path. Path to the folder, to which the current element must be unpacked.
The UnpackFile method unpacks the current element to the specified hard drive folder.
If the current element corresponds with the folder, all folder contents is unpacked with saving of all internal folders and files hierarchy.
Executing the example requires that the hard drive contains the archive: D:\Work\Archives\Data.zip. The archive contains folders and files, several of them can contain the Last text.
Add a link to the IO system assembly. On working in Fore.NET, add a link to the ForeIO assembly.
Sub UserProc;
Var
ZIP: IZipArchive;
ZIPEntry: IZipArchiveEntry;
Begin
ZIP := New ZipArchive.Create("D:\Work\Archives\Data.zip", ZipMode.Read);
For Each ZIPEntry In ZIP Do
If ZIPEntry.ArchPath.IndexOf("Last") <> -1 Then
ZIPEntry.UnpackFile("D:\Work\Files");
End If;
End For;
Dispose ZIP;
End Sub UserProc;
Imports Prognoz.Platform.Interop.ForeIO;
Public Shared Sub Main(Params: StartParams);
Var
ZIP: IZipArchive = New ZipArchiveClass();
ZIPEntry: IZipArchiveEntry;
Begin
ZIP.Create("D:\Work\Archives\Data.zip", ZipMode.zmRead, ZipCompressionLevel.zcDefaultCompression);
For Each ZIPEntry In ZIP Do
If ZIPEntry.ArchPath.IndexOf("Last") <> -1 Then
ZIPEntry.UnpackFile("D:\Work\Files");
End If;
End For;
System.Runtime.InteropServices.Marshal.ReleaseComObject(ZIP);
End Sub;
After executing the example archive elements are checked, if their names contain the Last text. If names contain the specified text, this folder or file are unpacked to the specified directory.
See also: