Solved

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

Posted on 2009-06-28
2
646 Views
Last Modified: 2012-05-07
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?
0
Comment
Question by:Asparona
2 Comments
 
LVL 15

Accepted Solution

by:
Praveen Venu earned 500 total points
ID: 24734500
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);
}
 
st.Close();
output.Close();

Open in new window

0
 

Author Closing Comment

by:Asparona
ID: 31597730
Thanks for your help!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
daypilot scheduler 3 27
Hey Audio! 3 29
Footer for each row on Gridview 2 21
Calculate number of nights between two dates 5 24
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question