my page is form, that creates 2 files when processing the submitted info, the files are closed and their objects are set to nothing and the very last of the process is a page redirect. however at that point, for instance i cannot delete the files, because they are still being used somehow by the asp process, the one that was created when the page was initially invoked.

see following for file code, its the same for both files:

Dim vcf As System.IO.StreamWriter
            vcf = System.IO.File.AppendText(appsPath & "\" & firstName.Text & "." & lastName.Text & ".vcf")
                etc, etc.
        vcf = Nothing

the process holding the files is aspnet.exe, if i try to delete, i get the windows msg, 'cannot delete..... It is being used by another person or program. Close any programs......'

i see in the default vs2005 global.asax file there is a comment for the session_end, see below. is that where i need to put some code to fully and finally end that particular page instance process? if so, not sure what is really needed there?

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

        ' Code that runs when a session ends.
        ' Note: The Session_End event is raised only when the sessionstate mode
        ' is set to InProc in the Web.config file. If session mode is set to StateServer
        ' or SQLServer, the event is not raised.
    End Sub

The process also opens, updates and closes an access db. it is fully released when the process ends, so at least that releases ok

7 Years
Discussion Span
Last Post by __avd

Use Using ... End Using

Dim file As String = MapPath("~/Test.txt")
        Using vcf = System.IO.File.AppendText(file)
        End Using
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.