Пример #1
0
Файл: File.cs Проект: blesh/ALE
        public const int DefaultBufferSize = 65536; //64KB

        #endregion Fields

        #region Methods

        /// <summary>
        /// Reads a file as a stream in chunks.
        /// </summary>
        /// <param name="path">The file path.</param>
        /// <param name="callback">Called when a chunk is read.</param>
        public static void Read(string path, Action<Exception, long, byte[]> callback)
        {
            var fs = System.IO.File.OpenRead(path);
            var buffer = new byte[DefaultBufferSize];
            var state = new ReadAsyncCallbackState(fs, buffer, callback);
            fs.BeginRead(buffer, 0, buffer.Length, ReadAsyncCallback, state);
        }
Пример #2
0
        public const int DefaultBufferSize = 65536; //64KB

        /// <summary>
        /// Reads a file as a stream in chunks.
        /// </summary>
        /// <param name="path">The file path.</param>
        /// <param name="callback">Called when a chunk is read.</param>
        public static void Read(string path, Action <Exception, long, byte[]> callback)
        {
            var fs     = System.IO.File.OpenRead(path);
            var buffer = new byte[DefaultBufferSize];
            var state  = new ReadAsyncCallbackState(fs, buffer, callback);

            fs.BeginRead(buffer, 0, buffer.Length, ReadAsyncCallback, state);
        }