Rename(Name: String);
Rename(Name: String);
Name. New name.
The Rename method renames file or folder in archive.
Executing the example requires the archive: D:\Work\Archives\Data.zip. The Other folder and the WDI.xls file with data are added to the archive.
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.Update);
ZIPEntry := ZIP.ItemByName("Other/");
ZIPEntry.Rename("Old");
ZIPEntry := ZIP.ItemByName("WDI.xls");
ZIPEntry.Rename("WDI_Old.xls");
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.zmUpdate, ZipCompressionLevel.zcDefaultCompression);
ZIPEntry := ZIP.ItemByName["Other/"];
ZIPEntry.Rename("Old");
ZIPEntry := ZIP.ItemByName["WDI.xls"];
ZIPEntry.Rename("WDI_Old.xls");
System.Runtime.InteropServices.Marshal.ReleaseComObject(ZIP);
End Sub;
After executing the example the specified folder and file are renamed in the Data.zip archive.
See also: