Solved

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

Posted on 2009-06-28
2
643 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
Comment Utility
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
Comment Utility
Thanks for your help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now