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 1072801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:54:36+00:00 2026-05-16T20:54:36+00:00

I want to zip one CSV file in to Zip file using C#.Net. Below

  • 0

I want to zip one “CSV” file in to Zip file using C#.Net. Below i have written some code for create Zip file , using this code i am able to create zip file but after creating “Data1.zip” file extract manually means extracted file extension should be “.csv” but it is not coming.

        FileStream sourceFile = File.OpenRead(@"C:\Users\Rav\Desktop\rData1.csv");
        FileStream destFile = File.Create(@"C:\Users\Rav\Desktop\Data1.zip");

        GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress,false);

        try
        {
            int theByte = sourceFile.ReadByte();
            while (theByte != -1)
            {
                compStream.WriteByte((byte)theByte);
                theByte = sourceFile.ReadByte();
            }
        }
        finally
        {
            compStream.Dispose();
        }
  • 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-16T20:54:37+00:00Added an answer on May 16, 2026 at 8:54 pm

    Use ICSharpCode.SharpZipLib(you can download it) and do the following

           private void CreateZipFile(string l_sFolderToZip)
           {
                FastZip z = new FastZip();
                z.CreateEmptyDirectories = true;
                z.CreateZip(l_sFolderToZip + ".zip", l_sFolderToZip, true, "");
    
                if (Directory.Exists(l_sFolderToZip))
                    Directory.Delete(l_sFolderToZip, true);   
    
          }
    
    
    
            private void ExtractFromZip(string l_sFolderToExtract)
            {
                string l_sZipPath ="ur folder path" + ".zip";
                string l_sDestPath = "ur location" + l_sFolderToExtract;
    
                FastZip z = new FastZip();
                z.CreateEmptyDirectories = true;
                z.ExtractZip(l_sZipPath, l_sDestPath, "");
    
                if (File.Exists(l_sZipPath))
                    File.Delete(l_sZipPath);
            }
    

    Hope it helps…

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

Sidebar

Related Questions

I have one zip file that i want unzip .the size of this file
I want to zip a file using PZKip in C# .net. I am using
I have zip file in ftp server,this zip file contain more then one xml
I have an existing ZIP file (with some files) where I want to add
I want to create a zip extractor for plugins that I create for asp.net
I want to pack the project into a zip-file and have the build date
I have 5 MemoryStreams. I want to create a new zip (Which will also
I'm trying to simulate some code that I have working with SQL but using
I want to compress multiple files into one zip. I am stuck with this
i want to move only zip file from one folder to another folder everyday.

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.