1

I am using SSZipArchive library to create password protected zip file. I have already done with unzip file where i didn't face any trouble. But when it's came to creation of zip file with password protection , it's not working at all.

let filePath = Bundle.main.path(forResource: "bg2", ofType: "jpg", inDirectory: "ZipFile")


    if filePath != nil{

        var paths = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)
        let documentsDir = paths[0]
        let zipPath =  documentsDir.appendingFormat("/MyZipFiles") // My folder name


        let fileManager = FileManager.default

        let success = fileManager.fileExists(atPath: zipPath) as Bool

        if success == false {

            do {

                try! fileManager.createDirectory(atPath: zipPath, withIntermediateDirectories: true, attributes: nil)
            }
        }


        let stat = SSZipArchive.createZipFile(atPath: zipPath, withFilesAtPaths: [filePath!], withPassword: "bt123")

        print(stat)
    }

While printing the value of stat which one the method createZipFile is returning, i am getting as false. but in this same way i already have done with unzip a zip file. so, please help me.

Thanks in advance.

AtulParmar
  • 4,358
  • 1
  • 24
  • 45
  • This might be help for you https://github.com/ZipArchive/ZipArchive/commit/a48f5d140acfb8f6192fa04a3500c3838dd16e41 – Mitesh jadav Mar 14 '19 at 07:12
  • @Miteshjadav why should i apply changes to unzip file? it's working fine for me. If there is anything might need to change than it should be inside zip file i guess. – Gopabandhu Mar 14 '19 at 07:28

0 Answers0