I see nowhere where you try to delete the file.
You can just use
Systme.IO.File.Delete(path);
, but there is no need to save the file to the file system anyway:
set up the image field as a varbinary(max):
Create Table images(
image_id int not null identity(1,1) primary key,
image_image1_name nvarchar(max),
image_image1_binary varbinary(max)
)
Then read the file stream directly from the upload. No need to save it, just keep it in memory as a byte[] for a couple of cycles.
byte[] input = new byte[picture1.ContentLength];
var stream = picture1.InputStream;
stream.Read(input, 0, picture1.ContentLength);
command.Parameters.Add("@image1Name", SqlDbType.VarChar, 100).Value=picture1.FileName;
command.Parameters.Add("@image1Byte", SqlDbType.VarBinary, file.Length).Value=input;
This is how I upload files all over the place. It's much faster and less hastle to clean up as the GC will bin the file when you're finished with it.
I hope that helps ^_^