aspnet_wp.exe has handle on directory being deleted

C

Chris McFarling

I have a basic aspx page for the user to select the month & year. They then
click a button to generate a report. The following sequence happens:

- Temp directory is created (if it exists already, it is deleted first)
- A simple aspx file is built in code and written to the temp directory with
a StreamWriter
- A View Report button is displayed for the user


The View Report button is a HyperLink control that targets a blank window.
When clicked the temp aspx file in the temp directory is displayed in the
window.

Once the temp aspx file is accessed, if the user tries to run the report
again, an error is thrown. It appears that aspnet_wp.exe has a handle on the
temp directory which interferes with the following code:

If Directory.Exists(strPath) = True Then
Directory.Delete(strPath, True)
End If
Directory.CreateDirectory(strPath)
....
dsDataSet.WriteXml(strPath & "\report.xml")
....
objStreamWriter.Write(strHtml)


The error only occurs the first time the report is run after viewing the
file. The error is caused by the WriteXml command not having a directory to
write to. So the directory gets deleted but it does not get recreated.
Re-running the report again at that poit is successfull.

Here's a summary of how to recreate the error:

Run report = success
Don't view file
Re-run report = success
View file
Re-run report = failure
Re-run report = success

This appears to be an issue where aspnet_wp.exe has a handle on a
file/directory that is part of the web application. Is there a way to keep
hat from happening?
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top