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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:37:04+00:00 2026-05-30T12:37:04+00:00

I have a simple application that retrieves a dataset from the database and converts

  • 0

I have a simple application that retrieves a dataset from the database and converts it to an xml file. This xml file is then read in and compressed to a .gz file.

This seems pretty inefficient – is it possible to skip the step of writing to a temporary .xml file and reading it back into compress it? Can I automatically send the file to a stream which converts it directly to a converted xml format?

Here is my code:

public partial class _Default : System.Web.UI.Page
{
    DataSet dataset = new DataSet();
    string uri = "C:\\tester.xml";
    string compressedfileuri = "C:\\tester.gz";

    protected void Page_Load(object sender, EventArgs e)
    {            
        //get the dataset
        RetrieveData();

        //serialize data to a xml file
        dataset.WriteXml(uri);

        //compress the data
        Compress();
    }

    public void RetrieveData()
    {
        string connString = ConfigurationManager.ConnectionStrings["Platform"].ConnectionString;
        using (SqlConnection conn = new SqlConnection(connString))
        {
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand("SELECT * FROM expenses.CST_COSTHEADER", conn);
            adapter.Fill(dataset);                
        }
    }

    public void Compress()
    {
        using (FileStream fs = new FileStream(uri, FileMode.Open))
        {
            using (FileStream outFile = File.Create(compressedfileuri))
            {
                using (GZipStream Compress = new GZipStream(outFile, CompressionMode.Compress))
                {
                    fs.CopyTo(Compress);
                }
            }
        }
    }
}
  • 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-30T12:37:05+00:00Added an answer on May 30, 2026 at 12:37 pm

    Why just not use following overload and write directly to ZIp stream?

    DataSet.WriteXml Method (Stream, XmlWriteMode)

    public void WriteXml(
        Stream stream,
        XmlWriteMode mode
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a console application that I am rebuilding from C to C#. This
I have a simple Desktop Facebook application that allows the user to retrieve some
I have a simple application that loads an unmanaged dll and passes a few
I have a simple c++ application that generates reports on the back end of
I have a simple iPhone application that is very similar to the Page Control
I have a simple test application (C# console application) that does an HTTP GET
I have got a Wavecom Supreme GSM modem. I wrote a simple application that
enter code here Hi All, I have a simple windows service application that connects
I have a simple message box in a WPF application that is launched as

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.