示例#1
0
        /// <summary>
        /// Compress the file asynchronously.
        /// </summary>
        /// <param name="dataFileFullName">Full name of the data file.</param>
        private void AsyncCompress(string dataFileFullName)
        {
            Thread t = new Thread(() =>
            {
                try
                {
                    Log.Info("Compressing file '{0}'...".FormatWith(dataFileFullName));
                    string compressedFileFullName = ZipHelper.CompressFile(dataFileFullName);
                    Log.Info("Compressed file '{0}' to '{1}'.".FormatWith(dataFileFullName, compressedFileFullName));

                    string destFullName = Path.Combine(Settings.Default.TransferFolder, Path.GetFileName(compressedFileFullName));
                    Log.Info("Copying file '{0}' to '{1}'...".FormatWith(compressedFileFullName, destFullName));
                    File.Copy(compressedFileFullName, destFullName, true);
                    Log.Info("Copied file '{0}' to '{1}'...".FormatWith(compressedFileFullName, destFullName));
                }
                catch (Exception ex)
                {
                    this.CompressAndCopyExceptions.Add(ExceptionHelper.CentralProcessSingle2(ex));
                }
            })
            {
                Name = "Compress Data File '{0}' and copy it to '{1}'".FormatWith(dataFileFullName, Settings.Default.TransferFolder), IsBackground = false
            };

            t.Start();
        }
        public async Task <Stream> ZipExcelFile()
        {
            var dic  = new Dictionary <string, Stream>();
            var item = await GenerateExcelFile();

            ZipHelper zip = new ZipHelper();

            dic.Add(item.Item2, item.Item1);
            return(await zip.CompressFile(dic, null));
        }