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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:56:40+00:00 2026-05-13T07:56:40+00:00

I try to follow the loading progress of big XML files (I’m not the

  • 0

I try to follow the loading progress of big XML files (I’m not the provider of these files) in dotnet (C#, framework 3.5 SP1) : from 1 MB to 300 MB over a network file share.

I use an XmlReader for loading purpose instead of direct XmlDocument.Load method for speed up the loading process.

By the way I found nowhere on internet/document on how to follow this loading progress: no delegates/events seem exist. Is there any way to perform this task ? Having the kind of functionnality for XML saving purpose could be a nice to have.

Thanks

  • 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-13T07:56:40+00:00Added an answer on May 13, 2026 at 7:56 am

    Assuming you are reading from a stream here is a (non-perfect) example of how to do it…
    Basically the ProgressStreamWrapper wraps the file stream and raises an event whenever Position is changed.

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Reading big file...");
    
            FileStream fileStream = File.OpenRead("c:\\temp\\bigfile.xml");
            ProgressStreamWrapper progressStreamWrapper = new ProgressStreamWrapper(fileStream);
            progressStreamWrapper.PositionChanged += (o, ea) => Console.WriteLine((double) progressStreamWrapper.Position / progressStreamWrapper.Length * 100 + "% complete");
            XmlReader xmlReader = XmlReader.Create(progressStreamWrapper);
    
            while (xmlReader.Read())
            {
                //read the xml document
            }
    
            Console.WriteLine("DONE");
            Console.ReadLine();
        }
    }
    
    
    public class ProgressStreamWrapper : Stream, IDisposable
    {
        public ProgressStreamWrapper(Stream innerStream)
        {
            InnerStream = innerStream;
        }
    
        public Stream InnerStream { get; private set; }
    
        public override void Close()
        {
            InnerStream.Close();
        }
    
        void IDisposable.Dispose()
        {
            base.Dispose();
            InnerStream.Dispose();
        }
    
        public override void Flush()
        {
            InnerStream.Flush();
        }
    
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            return InnerStream.BeginRead(buffer, offset, count, callback, state);
        }
    
        public override int EndRead(IAsyncResult asyncResult)
        {
            int endRead = InnerStream.EndRead(asyncResult);
            OnPositionChanged();
            return endRead;
        }
    
        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            return InnerStream.BeginWrite(buffer, offset, count, callback, state);
        }
    
        public override void EndWrite(IAsyncResult asyncResult)
        {
            InnerStream.EndWrite(asyncResult);
            OnPositionChanged(); ;
        }
    
        public override long Seek(long offset, SeekOrigin origin)
        {
            long seek = InnerStream.Seek(offset, origin);
            OnPositionChanged();
            return seek;
        }
    
        public override void SetLength(long value)
        {
            InnerStream.SetLength(value);
        }
    
        public override int Read(byte[] buffer, int offset, int count)
        {
            int read = InnerStream.Read(buffer, offset, count);
            OnPositionChanged();
            return read;
        }
    
        public override int ReadByte()
        {
            int readByte = InnerStream.ReadByte();
            OnPositionChanged();
            return readByte;
        }
    
        public override void Write(byte[] buffer, int offset, int count)
        {
            InnerStream.Write(buffer, offset, count);
            OnPositionChanged();
        }
    
        public override void WriteByte(byte value)
        {
            InnerStream.WriteByte(value);
            OnPositionChanged();
        }
    
        public override bool CanRead
        {
            get { return InnerStream.CanRead; }
        }
    
        public override bool CanSeek
        {
            get { return InnerStream.CanSeek; }
        }
    
        public override bool CanTimeout
        {
            get { return InnerStream.CanTimeout; }
        }
    
        public override bool CanWrite
        {
            get { return InnerStream.CanWrite; }
        }
    
        public override long Length
        {
            get { return InnerStream.Length; }
        }
    
        public override long Position
        {
            get { return InnerStream.Position; }
            set
            {
                InnerStream.Position = value;
                OnPositionChanged();
            }
        }
    
        public event EventHandler PositionChanged;
    
        protected virtual void OnPositionChanged()
        {
            if (PositionChanged != null)
            {
                PositionChanged(this, EventArgs.Empty);
            }
        }
    
        public override int ReadTimeout
        {
            get { return InnerStream.ReadTimeout; }
            set { InnerStream.ReadTimeout = value; }
        }
    
        public override int WriteTimeout
        {
            get { return InnerStream.WriteTimeout; }
            set { InnerStream.WriteTimeout = value; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just follow this DIHQuickStart , try to import data to solr from mysql.
I have two hashsets that are loading data from two different text files. The
I'm pulling in an XML file from the internet and loading it on the
I just typed the follow to try and get my SharePoint site: $spWeb =
I try to work with ctags and it simply doesn't work. I follow this
I am trying to follow this tutorial ( Using-core-plot-in-an-iphone-application ). When I try to
I am reading properties file from java DAO implementation for loading properties object as
I have a problem with retrieving information from a XML tree. My XML has
When I try to check the do not show this screen again box and
Here's three best practices I try to follow when naming tables: Never name a

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.