Error when sending a graphic by setting Response.ContentType

N

Nathan Sokalski

I am using an *.aspx page with a querystring to access graphics that I am
using in rollovers. I am using Response.ContentType and using
Response.WriteFile(). This sends the graphic perfectly fine, and in most
cases would work perfect. However, there are situations that I am running
into in which I want to delete the graphic file. When I try to do this, even
if a different rollover was the last one to use the page, I recieve a "The
process cannot access the file because it is being used by another process."
error. Is there something else I need to do? Here is my code:

Partial Public Class FileReader : Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim filepath As String = Request.QueryString("filepath").Replace("|"c,
"\"c)
Dim mimetype As String =
My.Computer.Registry.ClassesRoot.OpenSubKey(My.Computer.FileSystem.GetFileInfo(filepath).Extension).GetValue("Content
Type").ToString().ToLower()
Response.ClearContent()
Response.ContentType = mimetype
Response.WriteFile(filepath)
Response.End()
End Sub
End Class

I appreciate any help possible. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top