Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:58:38+00:00 2026-05-30T18:58:38+00:00

I do not seem to be able to write text via StreamWriter to a

  • 0

I do not seem to be able to write text via StreamWriter to a to be newly created zip file (not gzip). I use SharpZipLib and do not quite comprehend how to get it to work. DJ Kraze helped me with streaming content from a zipped text file to StreamReader, I now try the opposite. I do not want to create a csv file first and then compress the finalized file but like to stream text directly to a to be created csv within the zip container. Is that possible? Below a snippet I use for getting a stream that I can use with StreamReader, it just gives an idea what I am looking for, just that this time I like to get a stream to be used with StreamWriter.

public static Stream GetZipInputFileStream(string fileName)
{
    ZipInputStream zip = new ZipInputStream(File.OpenRead(fileName));
    FileStream filestream = 
        new FileStream(fileName, FileMode.Open, FileAccess.Read);
    ZipFile zipfile = new ZipFile(filestream);
    ZipEntry item;

    if ((item = zip.GetNextEntry()) != null)
    {
        return zipfile.GetInputStream(item);
    }
    else
    {
        return null;
    }
}

Here is how I use it, which I essentially look for but the other way around (StreamWriter -> new csv file in new zip container):

using (StreamReader streamReader = Path.GetExtension(fileName).ToUpper().Equals(".ZIP") ? new StreamReader(FileOperations.GetZipInputFileStream(fileName)) : new StreamReader(fileName))
            {
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:58:39+00:00Added an answer on May 30, 2026 at 6:58 pm

    I ended up dumping SharpZipLib for this purpose and instead went the more space intensive route of first unzipping all files in the zip container, processing the data and then moving the files back into the zip container. The problem I faced, as described above was that I could not read any of the files in the container at once due to their large size. It would be nice to see a zip library that may be able to handle partial stream writing into the container in the future but for now I did not see a way to get it done with SharpZipLib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem, which I do not seem to be able to solve...
I seem to not be able to do this (which I used to be
This code does not seem to compile, I just need to write something to
Excel macros do not seem to allow the use of undo after running them.
I'm having problems appending to a random-access file. I don't seem to be able
I want to write a following script: given a text file with the list
I'd like to be able to write/overlay text over an existing pdf document using
I'd like to be able to write the contents of a help file in
CLR profiler does not seem to work with the Silverlight CLR. Does another memory
This question might not seem programming related at first, but let me explain. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.