• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

How To Recreate Zip File From Request.Inputstream in ASP.Net Webpage

I have uploaded a zip file to a webpage (.aspx). The zip is located in the inputstream of the page.request object.

Can someone please let me know the method for reconstructing the zip from the inputstream property?
1 Solution
Praveen VenuTechnical Project ManagerCommented:
try this
StreamWriter tw = null;
Stream st = null;
FileStream output = null;
Page.Request.ContentType = "multipart/form-data";
string strFileNamePrefix = Page.Request.Headers.Get("FileName");
st = Page.Request.InputStream;
output = new FileStream(System.String.Concat(dirPath, strUnit, "\\", strDirectory, "\\", TimeStampInFileNameFormat(), ".zip"), FileMode.CreateNew);
Byte[] buffer = new Byte[4096];
int byteReads = st.Read(buffer, 0, 4096);
while (byteReads > 0)
output.Write(buffer, 0, byteReads);
byteReads = st.Read(buffer, 0, 4096);

Open in new window

AsparonaAuthor Commented:
Thanks for your help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now