0 votes
by (120 points)

We have a Zip service running in Linux container that will compress files from Windows network shared folder and save the Zip file to network shared folder. Currently we use UNC path and SMBLibrary open source libraries to access shared folders using Kerberos authentication:
https://github.com/ume05rw/EzSmb/tree/master
https://github.com/TalAloni/SMBLibrary

The challenge we are having ZipArchive to access shared folder to create and store compressed Zip file. Is there a way to use Rebex library to access network shared folder to create or read files?

Applies to: Rebex ZIP, Total Pack

1 Answer

0 votes
by (72.7k points)
edited by

Unfortunately, the SMB protocol is not supported by Rebex components directly.
Rebex.IO.Compression.ZipArchive uses System.IO.FileStream to handle string paths.

I was able to successfully read and write ZIP content using UNC paths in formats like:

new ZipArchive(@"\\server\home\user\data\test.zip")

new ZipArchive(@"\\?\h:\data\test.zip")

For the second case, adding following configuration section is needed if running on .NET 4.6.1 or lower.

<runtime>
    <AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false"/>
</runtime>

Please note that you can also initialize the ZipArchive using a stream (see ZipArchive(Stream)). If you are able to provide data from/to your shared folder using a stream, you can use this override.

Update: UNC paths are Windows-only. They won't work on Linux.

by (120 points)
Thank you for your feedback, we used SMB protocol (instead of System.IO.FileStream) to connect to file share, using user name and password, since our services are deployed in Linux containers. Like you said, we are focusing on initializing ZipArchive using stream. So far the challenge we have is creating empty writable/seekable stream using similar SMB protocol where the file path for the new ZIP archive will be network drive. Btw, Recently we have also worked on other proof of concepts like Sftp Upload/Download using Rebex library and IPWroks. Hopefully we figure out File Zip issue to adopt Rebex total pack soon.
...