How to receive a ZIP file in Asp.Net page

Hi,

I need to create a web site or page that will receive a Zip file sent to it via http. When I get the zip I'm going to open the file, do things with the contents and email them to some where else.

I'm used to dealing with zip files in a WinForm so I should be ok once I have the file.

Its been almost two years since I played with http and ASP.Net. I need to get my feet under me again and right now I'm drawing a HUGE blank. Can some one please get me started?

How can I tell when a zip file has been sent to the page? I assume every time someone hits my site or a particular page then the page_load event will fire for that page.

So I suppose I need a method to examine the http to look for a zip file every time the page_load fires?

Any help to get me going would be really appreciated.

Cheers
AsparonaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tapan PattanaikSenior EngineerCommented:

Upload to Database ... Dowload by Zip File:

http://www.codeproject.com/KB/aspnet/upsanddowns.aspx

Using the Zip Classes in the J# Class Libraries to Compress Files and Data with C#:

http://msdn.microsoft.com/hi-in/magazine/cc164129(en-us).aspx

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Snarf0001Commented:
You're correct about the page_load, and you need to be checking the Request.Files collection.  Assuming you're comfortable with the zip file as you say, then i'll leave it at either you can save the file to disk and do what you need to, or just read it into memory.

protected void Page_Load(object sender, EventArgs e)
{
    foreach(HttpPostedFile file in Request.Files)
    {
        //this would save the file to disk
        file.SaveAs(System.IO.Path.GetFileName(file.FileName));

        //with the file.InputStream, you could read into memory and manipulate that way
    }
}

Note 2 things, if you're going to have other functionality on that page (which i would assume you won't...), then wrap the foreach loop in a

if (!Page.IsPostBack)
{
}

for performance.
Also, be aware that the Request.Files will ONLY have files uploaded with "POST" and multipart form, NOT with the PUT method.
0
AsparonaAuthor Commented:
Thanks guys, this should be enough to get me going again. Its funny how fast I forget this stuff if I 'm not using the technology regularly.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.