TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
140
1.2k
Create Zip Using ionic
Mar 28 2018 3:23 AM
public static void CreateZipForCronjob(string PathForTheFilesToBeIncludedInZip, string PathForTheZip, string ZipName, DateTime Date, bool IsDateFilter = false)
{
using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
var FileNamesList = Directory.GetFiles(HttpContext.Current.Server.MapPath(PathForTheFilesToBeIncludedInZip), "*.pdf").ToList();
for (int i = 0; i < FileNamesList.Count; i++)
{
string filePath = FileNamesList[i];
if (IsDateFilter)
{
if (filePath.ToString().Contains(Date.ToString("dd-MMM-yyyy")))
{
zip.AddFile(filePath, ZipName);
}
}
else
{
zip.AddFile(filePath, ZipName);
}
}
zip.Save(HttpContext.Current.Server.MapPath(PathForTheZip) + ZipName);
for (int i = 0; i < FileNamesList.Count; i++)
{
string filePath = FileNamesList[i];
File.Delete(filePath);
}
}
}
Reply
Answers (
1
)
How to create XML attribute name with special character:
Checking and unchecking a checklistbox base on combo box val