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

  • Home
  • SEARCH
  • 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 7161369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:33:19+00:00 2026-05-28T13:33:19+00:00

I have been developing a web application with asp.net and I have smoe question

  • 0

I have been developing a web application with asp.net and I have smoe question about SharZipLib. I have a file called Template.odt (from Open Office) and this file is a compacted file (like docx) and we have some other files inside it (manifiest, xml, images etc). I need to open this file change a file called content.xml and styles.xml and save in another .odt file and give to my client. But I’m not sure if we can use temporary files, so I was thinking how to do this using MemoryStream.

Look what I got:

protected byte[ GetReport() {
    Stream inputStream = File.OpenRead(Server.MapPath("~/Odt/Template.odt"));
    var zipInputStream = new ZipInputStream(inputStream);
    var outputStream = new MemoryStream();
    var zipOutputStream = new ZipOutputStream(outputStream);
    ZipEntry entry = zipInputStream.GetNextEntry();
    while (entry != null) {     

        if (entry.Name == "content.xml") 
            // how change the content ?
        else if (entry.Name == "styles.xml") 
            // how change the content ?

        // how to add it or create folders in the output ?
        zipOutputStream.Write( ??? );

        entry = zipInputStream.GetNextEntry();
    }
    zipOutputStream.Flush();
    return outputStream.ToArray();
}

I’m not sure if it’s right but I think it’s on the way.

I try to take ExtraData from ZipEntry instance but I got it null, is it normal ?

Can someone help me?

Thank you

  • 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-28T13:33:20+00:00Added an answer on May 28, 2026 at 1:33 pm

    An example of how you can update ZIP files in memory can be found here:
    http://wiki.sharpdevelop.net/SharpZipLib_Updating.ashx#Updating_a_zip_file_in_memory_1

    In your case, you probably have to load content.xml into a XmlDocument or XDocument to modify it – but that depends on what you are trying to change exactly.

    As a sidemark: when using streams, make sure you are disposing of them. The easiest way is to wrap the operation in using statement:

       using(var inputStream = File.OpenRead(Server.MapPath("~/Odt/Template.odt")))
       {
          // ...
       }
    

    More information on that: http://www.codeproject.com/Articles/6564/Understanding-the-using-statement-in-C

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

Sidebar

Related Questions

I have a project (Web Application) which I have been developing in C#/ASP.NET, and
So I have been developing a small ASP.NET web app in C# for my
I have been developing a web application for about six months with no framework
I have an Asp.Net MVC Web Application that I am developing. I have TeamCity
I have been developing in asp.net since its existence (also classic asp before that)
I have been developing a web application for almost a year which I had
I have been developing a web application on XP and FF (with occasional IE
I am developing a stock/e-commerce web application. We have been using a version of
So I have been developing a web application, and I have implemented the HTML5
We have been working on developing a web application and I am currently researching

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.