Question

I am using mono and monobjc to develop an application to run on Mac OS X 10.6. I am adding some files to a zip file using ICSharpCode.SharpZip. The code is as -

var ms = new MemoryStream();
var zipStream = new ZipOutputStream(ms); 
zipStream.PutNextEntry(new ZipEntry(Path.GetFileName(file))
         {DateTime = File.GetCreationTime(file), 
          Size = new FileInfo(file).Length});

Sometimes, not always, The PutNewEntry code throws the following exception -

System.NotSupportedException: CodePage 437 not supported at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in :0 at ICSharpCode.SharpZipLib.Zip.ZipConstants.ConvertToArray (System.String str) [0x00000] in :0 at ICSharpCode.SharpZipLib.Zip.ZipConstants.ConvertToArray (Int32 flags, System.String str) [0x00000] in :0 at ICSharpCode.SharpZipLib.Zip.ZipOutputStream.PutNextEntry (ICSharpCode.SharpZipLib.Zip.ZipEntry entry) [0x00000] in :0 at (wrapper remoting-invoke-with-check) ICSharpCode.SharpZipLib.Zip.ZipOutputStream:PutNextEntry (ICSharpCode.SharpZipLib.Zip.ZipEntry)

I have the following two questions -

  1. What is the causing the above exception.
  2. It looks like ICSharp may not be the best option. What are the better alternatives?.
Was it helpful?

Solution

I fixed this by creating a tar.gzip instead of using zip. I used ICSharp itself to create the tar file. Mac does not seem to like zip. It could also be because I was using the ICSharp in Mono framework on Mac side and using ICSharp(download from the web) on the windows side. But using tar.gzip resolved this issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top