How can I rewrite the below?
//protected void UploadButton_Click(object sender, EventArgs e)
//{
// //get the image file that was posted (binary format)
// if (FileUpload1.PostedFile == null || FileUpload1.PostedFile.FileName == "")
// {
// lblResult.Text = "Please Select the file";
// }
// else
// {
// try
// {
// if (FileUpload1.HasFile)
// {
// Int32 length = FileUpload1.PostedFile.ContentLength;
// Byte[] theImage = new Byte[length];
// Bitmap image = ResizeImage(FileUpload1.PostedFile.InputStream, 300, 300);
// // Initialize the stream to read the uploaded file.
// System.IO.Stream myStream = FileUpload1.FileContent;
// theImage = BmpToBytes_MemStream(image);
// // Read the file into the byte array.
// myStream.Read(theImage, 0, length);
// string fileName = FileUpload1.FileName.ToString(); //get the file name of the posted image
// string type = FileUpload1.PostedFile.ContentType; //get the type of the posted image
// //Call the method to execute Insertion of data to the Database
// ExecuteInsert(theImage, type, length, fileName); //Big change here using the FileUpload.FileBytes property!
// lblResult.Text = "";
// lblResult.Text = "<br>";
// lblResult.Text += "File Content Type: " +
// FileUpload1.PostedFile.ContentType + "<br>";
// lblResult.Text += "File Size: " +
// FileUpload1.PostedFile.ContentLength + "kb<br>";
// lblResult.Text += "File Name: " +
// FileUpload1.PostedFile.FileName + "<br>";
// lblResult.Text += "Saved Successfully!";
// //GridView1.DataBind();
// }
// }
// catch (Exception Ex)
// {
// lblResult.Text += "Error: <br>" + Ex.Message;
// }
// }
//}
//protected void UploadButton_Click(object sender, EventArgs e)
//{
// //get the image file that was posted (binary format)
// if (FileUpload1.PostedFile == null || FileUpload1.PostedFile.FileName == "")
// {
// lblResult.Text = "Please Select the file";
// }
// else
// {
// try
// {
// if (FileUpload1.HasFile)
// {
// Int32 length = FileUpload1.PostedFile.ContentLength;
// Byte[] theImage = new Byte[length];
// Bitmap image = ResizeImage(FileUpload1.PostedFile.InputStream, 300, 300);
// // Initialize the stream to read the uploaded file.
// System.IO.Stream myStream = FileUpload1.FileContent;
// theImage = BmpToBytes_MemStream(image);
// // Read the file into the byte array.
// myStream.Read(theImage, 0, length);
// string fileName = FileUpload1.FileName.ToString(); //get the file name of the posted image
// string type = FileUpload1.PostedFile.ContentType; //get the type of the posted image
// //Call the method to execute Insertion of data to the Database
// ExecuteInsert(theImage, type, length, fileName); //Big change here using the FileUpload.FileBytes property!
// lblResult.Text = "";
// lblResult.Text = "<br>";
// lblResult.Text += "File Content Type: " +
// FileUpload1.PostedFile.ContentType + "<br>";
// lblResult.Text += "File Size: " +
// FileUpload1.PostedFile.ContentLength + "kb<br>";
// lblResult.Text += "File Name: " +
// FileUpload1.PostedFile.FileName + "<br>";
// lblResult.Text += "Saved Successfully!";
// //GridView1.DataBind();
// }
// }
// catch (Exception Ex)
// {
// lblResult.Text += "Error: <br>" + Ex.Message;
// }
// }
//}