Specify Encoding to Compress ZIP Archives with Japanese File Names/Paths (XL#78482)

Dear Aspose Support team,

This is Shin at XLsoft.

I got a question about the Aspose.ZIP for .NET specification.

Is it supported if the ZIP file name is Japanese ?
When he compressed a Japanese ZIP file, the contents were empty.

Can you think of any reasons?

best regards, Shin

@xlsoftkk

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input document that you want to compress.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

@xlsoftkk,

It should be supported, please try setting encoding while saving:

using (var archive = new Archive(...))
{
       ...
       archive.Save(zipFile, new ArchiveSaveOptions() { Encoding = Encoding.UTF8 });
}

We are not sure what might be the actual problem. Please provide sample files to analyze this issue on our end. We need both the compressed and original files for testing on our end.

Dear tahir.manzoor,

This is Shin at XLsoft.

Thank you for reply.

It seems difficult to provide sample files. Sorry.

I got Applicable code.
As follows;

“filePath” is the full path of the file to be zipped (including Japanese)
“zipPath” is the full path of the zip file

★1 “achv.CreateEntry(i, oneFile)” created a zip. A file with a numeric file name (1-20) was included in the zip.

★2 When “achv.CreateEntry(IO.Path.GetFileName(oneFile), oneFile)” is enabled, if you comment out ★1, a zip is created, but the contents of the zip are empty.


Using achv As Archive = _
New Archive()
Dim strFile As String() = System.IO.Directory.GetFiles(filePath)
If strFile.Length > 0 Then
For i = 0 To strFile.Length - 1
Dim oneFile As String = strFile(i)
achv.CreateEntry(i, oneFile) ★1
'achv.CreateEntry(IO.Path.GetFileName(oneFile), oneFile) ★2
Next
End If
achv.Save(zipPath)
End Using

best regards, Shin

Dear awais.hafeez,

This is Shin at XLsoft.

Thank you for reply.

It seems difficult to provide sample files. Sorry.

I got Applicable code.
As follows;

“filePath” is the full path of the file to be zipped (including Japanese)
“zipPath” is the full path of the zip file

★1 “achv.CreateEntry(i, oneFile)” created a zip. A file with a numeric file name (1-20) was included in the zip.

★2 When “achv.CreateEntry(IO.Path.GetFileName(oneFile), oneFile)” is enabled, if you comment out ★1, a zip is created, but the contents of the zip are empty.


Using achv As Archive = _
New Archive()
Dim strFile As String() = System.IO.Directory.GetFiles(filePath)
If strFile.Length > 0 Then
For i = 0 To strFile.Length - 1
Dim oneFile As String = strFile(i)
achv.CreateEntry(i, oneFile) ★1
'achv.CreateEntry(IO.Path.GetFileName(oneFile), oneFile) ★2
Next
End If
achv.Save(zipPath)
End Using

best regards, Shin

@xlsoftkk,

I am afraid, it is difficult to say what the problem actually is without having your sample compressed and original files. We need your files to reproduce the same problem on our end. Please note that it is safe to attach files in the forum. If you attach your files here, only you and Aspose staff members can download them. We will then investigate the issue on our end and provide you more information. Thanks for your cooperation.

Dear awais.hafeez,

This is Shin at XLsoft.

OK.
We will contact you as the situation progresses.

best regards, Shin

Dear awais.hafeez,

This is Shin at XLsoft.

Thanks to the encoding settings that I told you, the problem of empty files has been resolved.
Thank you for your cooperation.

best regards, Shin

@xlsoftkk,

It is great that you were able to find what you were looking for. Please let us know any time you have any further queries.