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
Santosh Vishwakarma
NA
76
5.6k
ASP.NET Create zip file for download: the compressed zipped
Jul 5 2019 6:46 AM
My problem seems only to be with the download. The code above executes without any issue. A file download dialog is presented. I can choose to either save or open. If I try to open the file from the dialog, or save it and then open it. I get the following dialog message:
The Compressed (zipped) Folder is invalid or corrupted.
my code
List<
string
> folderpath =
new
List<
string
>();
var zip =
new
ZipFile();
gridview.AllowPaging =
false
;
Response.ClearContent();
string
zipName = String.Format(
"Zip_{0}.zip"
, DateTime.Now.ToString(
"yyyy-MMM-dd-HHmmss"
));
Response.AddHeader(
"content-disposition"
,
"attachment; filename="
+ zipName);
Response.ContentType =
"application/zip"
;
System.IO.StringWriter sw =
new
System.IO.StringWriter();
HtmlTextWriter htw =
new
HtmlTextWriter(sw);
gridview.RenderControl(htw);
//byte[] toBytes = Encoding.ASCII.GetBytes(zipName);
MemoryStream stream =
new
MemoryStream();
string
attachment = sw.ToString();
byte
[] data = Encoding.ASCII.GetBytes(attachment);
stream.Write(data, 0, data.Length);
stream.Seek(0, SeekOrigin.Begin);
Reply
Answers (
1
)
How many languages .NET is supporting now?
Regarding AWS Development