Beispiel #1
0
 private void OnSingleFileProcessReport(long max, long position, string message)
 {
     if (!this.DesignMode)
     {
         if (SingleFileReporter != null)
         {
             SingleFileReporter.ChangeProgress(new I3ProgressingEventArgs(0, max, position, message));
         }
     }
 }
Beispiel #2
0
 private void OnTotalBytesProcessReport(long max, long position, string message)
 {
     if (!this.DesignMode)
     {
         if (TotalBytesReporter != null)
         {
             TotalBytesReporter.ChangeProgress(new I3ProgressingEventArgs(0, max, position, message));
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 将一个流写入另一个流中,失败返回false
        /// 从destStream的当前位置,将sourceStream从当前位置写入
        /// </summary>
        /// <param name="sourceFileName"></param>
        /// <param name="sourceStream"></param>
        /// <param name="zipOutPutStream"></param>
        /// <param name="BlockSize"></param>
        /// <param name="form"></param>
        public static I3MsgInfo WriteStreamToStream(string messageInfo, Stream sourceStream, Stream destStream,
                                                    int BlockSize, IProgressReporter progressReporter)
        {
            byte[] buffer = new byte[BlockSize];

            long longsize = 0;
            int  size     = sourceStream.Read(buffer, 0, buffer.Length);

            if (size == 0)
            {
                return(new I3MsgInfo(false, "源文件流大小为0!"));
            }

            destStream.Write(buffer, 0, size);
            longsize = size;
            if (progressReporter != null)
            {
                progressReporter.ChangeProgress(new I3ProgressingEventArgs(0, sourceStream.Length, longsize, messageInfo));
            }
            try
            {
                while (longsize < sourceStream.Length)
                {
                    size = sourceStream.Read(buffer, 0, buffer.Length);
                    destStream.Write(buffer, 0, size);
                    longsize += size;
                    if (progressReporter != null)
                    {
                        progressReporter.ChangeProgress(new I3ProgressingEventArgs(0, sourceStream.Length, longsize, messageInfo));
                    }
                }

                return(I3MsgInfo.Default);
            }
            catch (Exception ex)
            {
                return(new I3MsgInfo(false, ex.Message, ex));
            }
        }