/// <summary>
        /// Initializes a new instance of the <see cref="DBaseStreamReader" /> class.
        /// </summary>
        /// <param name="stream">The file stream.</param>
        /// <param name="encoding">The encoding of the file.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The stream is null.
        /// or
        /// The encoding is null.
        /// </exception>
        public DBaseStreamReader(Stream stream, Encoding encoding)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream", "The stream is null.");
            }
            if (encoding == null)
            {
                throw new ArgumentNullException("encoding", "The encoding is null.");
            }

            _stream   = stream;
            _encoding = encoding;
            _header   = new DBaseHeader(_stream);
            _disposed = false;
        }
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <param name="disposing">A value indicating whether disposing is performed on the object.</param>
        protected virtual void Dispose(Boolean disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                _stream.Dispose();
                _stream = null;

                _header = null;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DBaseStreamWriter" /> class.
        /// </summary>
        /// <param name="stream">The file stream.</param>
        /// <param name="encoding">The encoding of the file.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The stream is null.
        /// or
        /// The encoding is null.
        /// </exception>
        public DBaseStreamWriter(Stream stream, Encoding encoding)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream", "The stream is null.");
            }
            if (encoding == null)
            {
                throw new ArgumentNullException("encoding", "The encoding is null.");
            }

            _stream          = stream;
            _encoding        = encoding;
            _header          = new DBaseHeader();
            _headerWritten   = false;
            _numberOfRecords = 0;
            _disposed        = false;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DBaseStreamWriter" /> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="encoding">The encoding of the file.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The path is null.
        /// or
        /// The encoding is null.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// The path is empty, or consists only of whitespace characters.
        /// or
        /// The path is in an invalid format.
        /// </exception>
        /// <exception cref="System.IO.IOException">Exception occurred during stream opening.</exception>
        public DBaseStreamWriter(String path, Encoding encoding)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path", "The path is null.");
            }
            if (encoding == null)
            {
                throw new ArgumentNullException("encoding", "The encoding is null.");
            }

            if (String.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentException("The path is empty, or consists only of whitespace characters.", "path");
            }
            if (!Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out _path))
            {
                throw new ArgumentException("The path is in an invalid format.", "path");
            }

            try
            {
                if (_path.IsAbsoluteUri)
                {
                    _stream = FileSystem.GetFileSystemForPath(_path).CreateFile(_path.AbsolutePath, true);
                }
                else
                {
                    _stream = FileSystem.GetFileSystemForPath(_path).CreateFile(_path.OriginalString, true);
                }
            }
            catch (Exception ex)
            {
                throw new IOException("Exception occurred during stream opening.", ex);
            }

            _encoding        = encoding;
            _header          = new DBaseHeader();
            _headerWritten   = false;
            _numberOfRecords = 0;
            _disposed        = false;
        }