C# 解压时拆分大文本文件(SharpZipLib)

C# 解压时拆分大文本文件(SharpZipLib),c#,sharpziplib,C#,Sharpziplib,我使用以下代码解压文件(文本文件),然后用CSV解析器将其读入内存,并根据需要进行操作。这是没有问题的,但是我在一些zip驱动器中有一些相当大的文件,因为我的代码的其余部分是并行的,所以使用三个100MB的文件比使用一个300MB的文件运行得更快(而且不太容易出错) 这里是我当前的解压缩代码(使用ICSharpCode.SharpZipLib.dll): 我可以很明显地解压缩、拆分,然后读入内存,但这看起来很麻烦。我的问题是: 我可以调整上面的代码,以便在超过阈值后立即写入不同的输出文件吗?所以

我使用以下代码解压文件(文本文件),然后用CSV解析器将其读入内存,并根据需要进行操作。这是没有问题的,但是我在一些zip驱动器中有一些相当大的文件,因为我的代码的其余部分是并行的,所以使用三个100MB的文件比使用一个300MB的文件运行得更快(而且不太容易出错)

这里是我当前的解压缩代码(使用ICSharpCode.SharpZipLib.dll):

我可以很明显地解压缩、拆分,然后读入内存,但这看起来很麻烦。我的问题是:

我可以调整上面的代码,以便在超过阈值后立即写入不同的输出文件吗?所以,如果文件限制为100MB,解压后的总大小为287MB,我想提取到3个文件

  public static void ExtractZipFile(string archiveFilenameIn, string password, string outFolder)
    {
        //unzip function based on SharpZipLib (external ref dll)
        ZipFile zf = null;
        try
        {
            FileStream fs = File.OpenRead(archiveFilenameIn);
            zf = new ZipFile(fs);
            if (!String.IsNullOrEmpty(password))
            {
                zf.Password = password;     
            }
            foreach (ZipEntry zipEntry in zf)
            {
                if (!zipEntry.IsFile)
                {
                    continue;           // Ignore directories
                }
                String entryFileName = zipEntry.Name;

                byte[] buffer = new byte[4096];     // 4K is optimum
                Stream zipStream = zf.GetInputStream(zipEntry);

                String fullZipToPath = Path.Combine(outFolder, entryFileName);
                string directoryName = Path.GetDirectoryName(fullZipToPath);
                if (directoryName.Length > 0)
                    Directory.CreateDirectory(directoryName);
                using (FileStream streamWriter = File.Create(fullZipToPath))
                {
                    StreamUtils.Copy(zipStream, streamWriter, buffer);
                }
            }
        }
        finally
        {
            if (zf != null)
            {
                zf.IsStreamOwner = true; // Makes close also shut the underlying stream
                zf.Close(); // Ensure we release resources
            }
        }
    }