• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1523
  • Last Modified:

Download multiple files from server to client through .Net/C# code

We have an application developed in .Net 1.1 C# in which we are storing employee information in an Oracle 9i database and also storing jpg images of the employees in a specific folder on the application server.  The URL / location of these jpg images are stored against the employee record in the database.

The requirement right now is that the application displays the list of employees with checkboxes next to each, and the user will select some of the employees by checking the relevant checkboxes.  The user will then click on a "Download" button.  The application then needs to pick up the relevant data of all the selected employees and save it to the user's client PC in a single Excel file.  Next, the application also needs to save the jpg image file (photo) of the relevant employees into the same folder on the client PC.  In other words, if 5 employees are selected, then on clicking Download, we expect to generate 1 Excel file with relevant details of all 5 employees, and also 5 jpg files each being the photograph one of the employees selected.

We are successfully able to generate the Excel file and throw a Save dialog box to the user for saving the same on his PC.  We are unable to code for saving the jpg files on his PC.  We require a solution for this problem.
0
felixdsouza
Asked:
felixdsouza
  • 2
1 Solution
 
ColemssCommented:
This displays the data in a picturebox. use the bitmap to save it where you want.

String key = textBox1.Text;
            //
            // Create select command to get thumnail image using the ID
            //
            OracleCommand cmd = new OracleCommand
                ( "Select t.image.getContent(), t.thumb.getMimetype() from Photos t " +
                "where t.id= :v1", dbConn);
            OracleParameter paramID = new OracleParameter("id", OracleDbType.Int32,
                System.Convert.ToUInt32(key),
                ParameterDirection.Input);
            cmd.Parameters.Add(paramID);
 
            //
            // Execute the command as a reader commmand
            //
            OracleDataReader reader = cmd.ExecuteReader();
            if (!reader.Read())
            {
                textBox2.Text = "No data found for " + cmd.CommandText;
                return;
            }
 
            //
            // Obtain the binary data and mimetype from the SELECT
            //
            OracleBlob blob = reader.GetOracleBlob(0);
 
            Bitmap image = new Bitmap(blob);
            pictureBox1.Image=image;
0
 
felixdsouzaAuthor Commented:
Hi,

Thanks for the effort, but my application is a Web Application and not a Windows Application.  I need some code that will work for a Web application.
0
 
felixdsouzaAuthor Commented:
We have solved this problem by creating a zip file on the webserver and downloading the zip to the client's PC.  Hence closing this question.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now