Search code examples
vb.netpersiansharpziplib

ZipEntry() and converting persian filenames


In my vb.net project I'm trying to add a file with a Persian name to a zip file and I do this with the code bellow:

Dim myentry As New ZipEntry(dr.Item("MyFile").ToString())
zipOut.PutNextEntry(myentry)

however when I open the zip file I see the file name is changed to a gibberish

Is there a way to fix this problem? thanks in advance


Solution

  • Try setting IsUnicodeText to true:

    'VB.NET
    Dim newEntry = New ZipEntry(entryName) With { _
            Key .DateTime = DateTime.Now, _
            Key .Size = size, _
            Key .IsUnicodeText = True _
        }
    
    //C#
    var newEntry = new ZipEntry(entryName)
                {
                    DateTime = DateTime.Now,
                    Size = size,
                    IsUnicodeText = true
                };