How Can We Help?
   			
		Zip single file
Overview
The Zip File function compresses a single file into a ZIP archive. This is the simplest compression operation in Archive Manager Pro, perfect for quick file compression tasks.
Function Description
Node Name: Zip File
Category: Archive Manager
Type: Synchronous (blocking operation)
Compresses a single specified file and creates a ZIP archive containing that file. The operation completes immediately and returns a boolean indicating success or failure.
Input Parameters
| Parameter | Type | Description | 
|---|---|---|
| Path to File | String | Full absolute path to the file you want to compress | 
| Path to Zip | String | Full absolute path where the ZIP file should be created | 
| Delete After Compression | Boolean | If true, deletes the original file after successful compression | 
Output Parameters
| Parameter | Type | Description | 
|---|---|---|
| Return Value | Boolean | trueif compression succeeded,falseif it failed | 
Setup Steps
1. Add the Zip File Node
- In your Blueprint, right-click in the Event Graph
- Search for “Zip File”
- Add the Zip File node from the Archive Manager category
2. Configure Input Paths
- Path to File: Enter the full path to your source file
- Example: F:\Repos\test\ArchiveManager\sample_text.txt
 
- Example: 
- Path to Zip: Enter the full path for the output ZIP file
- Example: F:\Repos\test\ArchiveManager\single-file.zip
 
- Example: 
3. Set Compression Options
- Delete After Compression:
- ☑️ Checked: Original file is deleted after successful compression
- ☐ Unchecked: Original file is preserved (recommended for safety)
 
4. Handle the Result
- Connect the Return Value to a Branch node
- True branch: Compression succeeded – add success actions
- False branch: Compression failed – add error handling
5. Add Feedback (Recommended)
- Connect a Print String node to show operation status
- Example: “File zipped successfully!” or use Get Last Archive Error for failure details
Example Blueprint Setup
Common Use Cases
- Single document backup: Compress important files before operations
- File preparation: Compress files before upload or transfer
- Space optimization: Reduce file size for storage
- Archive creation: Create compressed versions of configuration files
Error Handling
If the operation fails (returns false), use the Get Last Archive Error node to retrieve specific error information:
- File not found
- Insufficient disk space
- Permission denied
- Invalid file path
Best Practices
- Always check the return value before proceeding
- Use absolute paths to avoid path resolution issues
- Test with small files first before processing large files
- Keep Delete After Compression unchecked until you’re confident in your setup
- Implement error handling to provide user feedback
Performance Notes
- This is a synchronous operation – it will block until complete
- For large files, consider using Zip Files (async) instead
- Memory usage scales with file size during compression
C++ Usage
Basic Implementation
#include "ArchiveManagerBPLibrary.h"
// Single file compression
FString InputFile = TEXT("C:/MyFiles/document.txt");
FString OutputZip = TEXT("C:/MyFiles/document.zip");
bool DeleteOriginal = false;
bool Success = UArchiveManagerBPLibrary::ZipFile(InputFile, OutputZip, DeleteOriginal);
if (Success)
{
    UE_LOG(LogTemp, Log, TEXT("File compressed successfully: %s"), *OutputZip);
}
else
{
    FString Error = UArchiveManagerBPLibrary::GetLastArchiveError();
    UE_LOG(LogTemp, Error, TEXT("Compression failed: %s"), *Error);
}With error handling
bool CompressSingleFile(const FString& FilePath, const FString& ZipPath)
{
    // Validate input file exists
    if (!FPaths::FileExists(FilePath))
    {
        UE_LOG(LogTemp, Error, TEXT("Input file does not exist: %s"), *FilePath);
        return false;
    }
    
    // Ensure output directory exists
    FString OutputDir = FPaths::GetPath(ZipPath);
    if (!FPaths::DirectoryExists(OutputDir))
    {
        IFileManager::Get().MakeDirectory(*OutputDir, true);
    }
    
    // Perform compression
    bool Result = UArchiveManagerBPLibrary::ZipFile(FilePath, ZipPath, false);
    
    if (!Result)
    {
        FString ErrorMsg = UArchiveManagerBPLibrary::GetLastArchiveError();
        UE_LOG(LogTemp, Error, TEXT("Zip operation failed: %s"), *ErrorMsg);
    }
    
    return Result;
}Integration with game systems
// In a save game system
UCLASS()
class MYGAME_API USaveGameManager : public UObject
{
    GENERATED_BODY()
    
public:
    UFUNCTION(BlueprintCallable)
    bool CompressSaveFile(const FString& SaveFileName)
    {
        FString SavePath = FPaths::ProjectSavedDir() / TEXT("SaveGames") / SaveFileName;
        FString ZipPath = SavePath + TEXT(".zip");
        
        return UArchiveManagerBPLibrary::ZipFile(SavePath, ZipPath, true); // Delete original
    }
};
