I wrote this script to create thumbnails. Most of the time it works fine, but once in a while ASP.NET locks the file and I get this error: The process cannot access the file 'my_file.jpg' because it is being used by another process. Anyone know what is going on a a fix?
Sub ResizeImage()
Dim bmpOriginal As New System.Drawing.Bitmap(Server.MapPath("im... %26amp; Request("photo")))
Dim bmpNew As New System.Drawing.Bitmap(bmpOriginal, 100, 100)
Response.ContentType = "image/gif"
bmpNew.Save(Server.MapPath("images/temp/... %26amp; Request("photo")), System.Drawing.Imaging.ImageFormat.Jpeg )
System.IO.File.Copy(Server.MapPath("im... %26amp; Request("photo")), Server.MapPath(".images/" %26amp; Request("photo")), True)
System.IO.File.Delete(Server.MapPath("im... %26amp; Request("photo")))
bmpOriginal.Dispose()
bmpNew.Dispose()
Response.Redirect ("default.asp?action=done")
End
ASP.NET The process cannot access the file because it is being used by another process! How can I fix it??internet explorer update
you might need to close the handle to the BMP file, Dispose() might not do the trick.
The other thing you can do is put a lock {... } statement around the function body, this way it will be threadsafe, which it currently isn't.
What line is the exception thrown on?
No comments:
Post a Comment