Click here to Skip to main content
15,891,809 members
Articles / Web Development / IIS

SharpBITS.NET - A Wrapper for the BITS API

Rate me:
Please Sign up or sign in to vote.
4.83/5 (22 votes)
7 Oct 2010CPOL4 min read 184.6K   4.3K   137  
A BITS wrapper library for .NET 2.0.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace SharpBits.Base
{
    public class BitsFiles: List<BitsFile>, IDisposable
    {
        private IEnumBackgroundCopyFiles fileList;
        private BitsJob job;
        private bool disposed;

        internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList)
        {
            this.fileList = fileList;
            this.job = job;
            this.Refresh();
        }

        internal void Refresh()
        {
            uint count;
            IBackgroundCopyFile currentFile;
            uint fetchedCount = 0;
            this.fileList.Reset();
            this.Clear();
            this.fileList.GetCount(out count);
            for (int i = 0; i < count; i++)
            {
                this.fileList.Next(1, out currentFile, out fetchedCount);
                if (fetchedCount == 1)
                {
                    this.Add(new BitsFile(this.job, currentFile));
                }
            }
        }

        #region IDisposable Members

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    //TODO: release COM resource
                    this.fileList = null;
                }
            }
            disposed = true;
        }


        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Svalbard and Jan Mayen Svalbard and Jan Mayen
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions