Exemple #1
0
        private bool WillowValleySendEmail(WillowValley objWillowValley, string folder)
        {
            var filesCol = objWillowValley.GetFile(folder).ToList();

            using (var memoryStream = new MemoryStream())
            {
                using (var ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                {
                    for (int i = 0; i < filesCol.Count; i++)
                    {
                        ziparchive.CreateEntryFromFile(filesCol[i].FilePath, filesCol[i].FileName);
                    }
                }
                MemoryStream attachmentStream = new MemoryStream(memoryStream.ToArray());
                return(Email.SendEmail(attachmentStream, folder, true));
            }
        }
Exemple #2
0
        private ActionResult GenarateZip(WillowValley objWillowValley, string folder, bool sendEmail)
        {
            var filesCol = objWillowValley.GetFile(folder).ToList();

            using (var memoryStream = new MemoryStream())
            {
                using (var ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                {
                    for (int i = 0; i < filesCol.Count; i++)
                    {
                        ziparchive.CreateEntryFromFile(filesCol[i].FilePath, filesCol[i].FileName);
                    }
                }
                MemoryStream attachmentStream = new MemoryStream(memoryStream.ToArray());
                if (sendEmail)
                {
                    Email.SendEmail(attachmentStream, folder, true);
                }
                return(File(memoryStream.ToArray(), "application/zip", "WillowValley.zip"));
            }
        }