PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Calculating the size of the files to extract from an archive
Calculating the size of the files to extract from an archive
WINDEVWEBDEV - Server codeWindowsAjaxUser code (UMC) The following code is used to check whether there is enough disk space to extract all the files from an archive. To do so, the uncompressed size of all the files found in an archive is compared to the available disk space (fDriveInfo).
// Declare and initialize the variables
ArchiveName is string = "MyArchive"
ErrorCodeOpen is int
ErrorCodeExtract is int
DiskSize is real
 
// Open an archive
ErrorCodeOpen = zipOpen(ArchiveName, "C:\Directory\Archives\ArchivePdf.wdz")
 
IF ErrorCodeOpen = 0 THEN
// Extract the files from the archive
IF YesNo("Do you want to extract all the files from the archive?") THEN
// Calculate the available space
DiskSize = fDriveInfo("C:\Temp", fdFreeSpace)
// Is there enough disk space?
IF DiskSize > zipSize(ArchiveName) THEN
// Extract all the files from the archive
ErrorCodeExtract = zipExtractAll(ArchiveName, zipDirectory)
// Error message if the files have not been extracted
IF ErrorCodeExtract <> 0 THEN
Error(zipMsgError(ErrorCodeExtract))
END
ELSE
// Insufficient disk space
Info("Insufficient space to extract the files")
END
END
ELSE
// Display an error message if the archive was not opened
Error(zipMsgError(ErrorCodeOpen))
END
 
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment