Created
June 22, 2022 11:29
-
-
Save InfRandomness/b85767c1db780cf6bd9658d7c91a5db0 to your computer and use it in GitHub Desktop.
ZIPFoundation basic code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import ZIPFoundation | |
let fileManager = FileManager() | |
let currentWorkingPath = fileManager.currentDirectoryPath | |
var sourceURL = URL(fileURLWithPath: currentWorkingPath) | |
sourceURL.appendPathComponent("file.txt") | |
var destinationURL = URL(fileURLWithPath: currentWorkingPath) | |
destinationURL.appendPathComponent("archive.zip") | |
do { | |
try fileManager.zipItem(at: sourceURL, to: destinationURL) | |
} catch { | |
print("Creation of ZIP archive failed with error:\(error)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment