[BigZip] ZipLoadMemory error 'Cannot create a file when that file already exists'

Forge Component
Published on 2019-06-28 by Kilian Hekhuis
10 votes
Published on 2019-06-28 by Kilian Hekhuis

Hi all,

Since the upgrade to Outsystems 11 we face some issues with the BigZip extension.

We use the following actions to get the zip file and unload it (see also the attached screenshot):

  • ZipLoadMemory
  • FileGetMemoryFromZip
  • ZipUnload

These are exactly the same actions as we used on version 10, but now sometimes we get the following error, but sometimes it also downloads the file. For example, if I try to download the file 4 times, it works 2 times and 2 times it throws the following error.

Cannot create a file when that file already exists.

Cannot create a file when that file already exists.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
at OutSystems.NssBigZip.ZipHandle.TmpZipNameGet()
at OutSystems.NssBigZip.ZipHandle..ctor(Byte[] content, String inpath, String password, String& outpath)
at OutSystems.NssBigZip.CssBigZip.MssZipLoadMemory(Byte[] ssZipBinary, String ssFilePath, String ssPassword, Object& ssZipHandle, String& ssFilePathCreated)
at ssEZIS_AzureCommon.RssExtensionBigZip.MssZipLoadMemory(HeContext heContext, Byte[] inParamZipBinary, String inParamFilePath, String inParamPassword, Object& outParamZipHandle, String& outParamFilePathCreated)

We didn't set the FilePath input in the action ZipLoadMemory, but it seems like this can't be the issue, since it creates a new file name on the Temp location. When I try it on Test environments, the error doesn't pop-up and everything seems to work fine.

Any ideas what goes wrong and how we can fix this?


Hi Jordy,

I haven't got a clue, what goes wrong here. This is the offending code:

static private string TmpZipNameGet()
   string tmpFileName = Path.GetTempFileName();
   string zipFileName = Path.ChangeExtension(tmpFileName, "zip");
   File.Move(tmpFileName, zipFileName);

   return zipFileName;

It's the File.Move that causes the exception. Given the error message, it seems that the zipFileName already exists, which is only possible if tmpFileName is the same as a previous temporary file - which shouldn't happen. However, the description of Path.GetTempFileName() says:


This method creates a temporary file with a .TMP file extension. The temporary file is created within the user's temporary folder, which is the path returned by the GetTempPath method.

The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files.

The GetTempFileName method will raise an IOException if no unique temporary file name is available. To resolve this error, delete all unneeded temporary files.

So it could be that there are a lot of ZIP files created, and never deleted, which causes the temporary names to run out. Since the TMP files are renamed to ZIP, the GetTempFileName itself doesn't cause an exeception, but the resulting ZIP file still exists.

I'm not sure how to resolve this: obviously, when creating a temporary ZIP file, you should delete it after use, or the TEMP directory will grow endlessly. Also, I'm not sure whether I should delete the temporary ZIP file before moving, as this could cause problems as well.


Hi Kilian,

Thanks for your quick reply. One of the remarks was actually the problem. On one server we had +- 75.000 files and on the other one 34.000. This also explained why it works sometimes, and sometimes not, due to the load balancer.

After clearing the folders (which had temp files of more than 1 year old) the issue was solved. And to prevent this in the future, we will clear the folder on monthly basis.

Hi Jordy,

Good to hear you got this solved. And thanks for using BigZip :). Happy coding!