How 7-Zip Handles Temp Files When Creating Archives
When creating or modifying compressed archives, 7-Zip relies on temporary files to preserve data integrity, optimize processing speed, and interface with the Windows file system. This article explains where 7-Zip creates temporary files, the operational difference between direct compression and updating existing archives, how drag-and-drop operations trigger temporary storage, and how users can configure these behaviors within the application settings.
Direct Creation vs. Updating Existing Archives
When creating a brand-new archive using the 7-Zip File Manager or the
standard context menu ("Add to archive..."), 7-Zip typically bypasses
the system's global temporary directory. Instead, it streams the
compressed data directly to the specified target destination under a
temporary filename (such as filename.7z.tmp). Once the
compression process completes and integrity checks pass, 7-Zip renames
the temporary file to the final target name (filename.7z).
This atomic write process ensures that if an operation is canceled or
fails, the target destination is not left with a corrupted, partially
written file bearing the final archive name.
When modifying or adding files to an existing archive, 7-Zip cannot simply insert data in place due to how solid compression blocks function. It creates a new temporary archive in the same directory as the original file, copies the unmodified content along with the newly compressed files into the new container, and then deletes the original archive before renaming the temporary archive.
The Drag-and-Drop Exception
Drag-and-drop interactions in Windows handle data through the standard Windows Shell (OLE/COM interfaces), which introduces a constraint: Windows Explorer cannot receive a stream of compressed data dynamically before knowing the target file path.
When you drag files directly into or out of the 7-Zip File Manager window:
- 7-Zip is forced to extract or compress the contents into the
operating system's temporary directory first (typically
%USERPROFILE%\AppData\Local\Temp). - Once the operation finishes in the temporary directory, Windows Explorer moves the generated files to the actual drop destination.
This workflow can lead to disk space bottlenecks and slow transfer speeds when handling large archives, as data must be written twice across disk sectors.
Temporary File Cleanup and Failure Handling
7-Zip automatically deletes its temporary files upon the successful completion of an operation or when the process is cleanly canceled by the user. However, temporary files may remain on the disk under specific failure conditions:
- Sudden system crashes, power loss, or forced termination via Task Manager prevent 7-Zip from executing its cleanup routines.
- Prematurely closing the 7-Zip interface before the Windows Shell
finishes transferring drag-and-drop files out of the
%TEMP%directory can leave stranded folders (often named starting with7zEor similar prefixes).
Configuring Temporary Folder Locations
Users can control where 7-Zip stores its temporary data to prevent filling up system drives or to boost performance using faster storage drives. Within the 7-Zip File Manager, navigate to Tools > Options > Folders to select from three settings:
- System temp folder: The default configuration,
utilizing the standard Windows
%TEMP%path. - Current folder: Forces 7-Zip to generate temporary operational files in the working directory of the source data or active archive, avoiding system drive usage.
- Specified folder: Allows the user to define a static path on a high-capacity drive or a high-speed NVMe SSD dedicated to compression workloads.