Error when sending a graphic by setting Response.ContentType

Discussion in 'ASP .Net' started by Nathan Sokalski, Dec 18, 2007.

  1. 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.
    Nathan Sokalski, Dec 18, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alien2_51

    Response.ContentType

    alien2_51, Jun 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    745
    alien2_51
    Jun 26, 2003
  2. Bart Vanwesemael
    Replies:
    1
    Views:
    515
    William F. Robertson, Jr.
    Jul 28, 2003
  3. TJS
    Replies:
    5
    Views:
    1,042
    Alvin Bruney
    Nov 19, 2003
  4. 50 SOMETHING GAL
    Replies:
    3
    Views:
    392
  5. Katie
    Replies:
    8
    Views:
    255
    Anthony Jones
    Aug 17, 2006
Loading...

Share This Page