Posts

Post marked as solved
1 Replies
368 Views
The ZIP file (sample.zip) contains the Cocoa application file (sample.app). If you copy the ZIP file (sample-new.zip) and extract it using the following code, the contents of the extracted folder (sample.app) are the same when compared by diff. However it is not recognized as an Cocoa application.  sample.app is converted to AppleDouble format in advance using ditto -c-k. using System.IO.Compression; var zipFileName = "sample.zip"; var newZipFileName = "sample-new.zip"; var zipPath = $@"./data/{zipFileName}"; var newZipPath = $@"./data/{newZipFileName}"; // open ZIP file. using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Read)) using (var memoryStream = new MemoryStream()) using (var newArchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) { foreach (var entry in archive.Entries) { var newEntry = newArchive.CreateEntry(entry.FullName); using var archiveEntry = entry.Open(); using var newArchiveEntry = newEntry.Open(); archiveEntry.CopyTo(newArchiveEntry); } newArchive.Dispose(); using var fileStream = new FileStream(newZipPath, FileMode.Create); memoryStream.Seek(0, SeekOrigin.Begin); // create new zip file memoryStream.CopyTo(fileStream); } I would like to know why it is not recognized as an application even though the files in the folder are the same. This sample.app will of course work if copied in Finder app, but I don't know if it's because the Application file is missing some specification or why copying in code doesn't work. Thanks.
Posted
by fujimori.
Last updated
.