Solved

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

Posted on 2009-06-28
2
644 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

911 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

22 Experts available now in Live!

Get 1:1 Help Now