protected void btn_upload_Click(object sender, EventArgs e)
{
if (FileUpload_barcode_image.HasFile)
{
if (FileUpload_barcode_image.PostedFile.ContentType == "image/gif") //Check that only .gif images are uploaded.
{
if (FileUpload_barcode_image.PostedFile.ContentLength < 102400) //Check that Image size is below 1024 KB or 1 MB.
{
file_name = Path.GetFileName(FileUpload_barcode_image.FileName); //using System.IO;is needed for the "Path" .
//Delete Old file before uploading new file.
if (System.IO.File.Exists(Server.MapPath("~/UPLOAD IMAGE/") + file_name))
{
System.IO.File.Delete(Server.MapPath("~/UPLOAD IMAGE/") + file_name);
}
FileUpload_barcode_image.SaveAs(Server.MapPath("~/UPLOAD IMAGE/") + file_name);
lbl_upload_status.Text = "BarCode Image UPLOADED Successfully!";
}
else
{
lbl_upload_status.Text = "Please UPLOAD An Image of Size Less Than 1MB!";
}
}
else
{
lbl_upload_status.Text = "Please UPLOAD IMAGE of .gif extension only!";
}
}
else
{
lbl_upload_status.Text = "Please Choose An Image To UPLOAD!";
}
}
when first time i upload an image for processing the image to decode the barcode the result is fine.But when i upload the same image again it gives error that "The Process Can't access the file "location of image" because it is being used by another process."