?
Solved

How to receive a ZIP file in Asp.Net page

Posted on 2009-06-27
3
Medium Priority
?
417 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:Asparona
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 1000 total points
ID: 24727339

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
 
LVL 23

Assisted Solution

by:Snarf0001
Snarf0001 earned 1000 total points
ID: 24727739
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
 

Author Closing Comment

by:Asparona
ID: 31597274
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

801 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