Link to home
Start Free TrialLog in
Avatar of felixdsouza
felixdsouzaFlag for India

asked on

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.
Avatar of Colemss
Colemss
Flag of United States of America image

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;
Avatar of felixdsouza

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of felixdsouza
felixdsouza
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial