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
        Try
            vcf = System.IO.File.AppendText(appsPath & "\" & firstName.Text & "." & lastName.Text & ".vcf")
                etc, etc.
        vcf.close()
        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

Use Using ... End Using

Dim file As String = MapPath("~/Test.txt")
        Using vcf = System.IO.File.AppendText(file)
            vcf.WriteLine("Hi")
            vcf.Flush()
            vcf.Close()
        End Using
        System.IO.File.Delete(file)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.