Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


write to temp file & delete it

Posted on 2005-05-02
Medium Priority
Last Modified: 2010-05-18

I'm trying to write some text to a file:

StreamWriter sw = new StreamWriter(filePath, false))

then later i need to delete the file:

// get rid of the file

but i get an exception when i try to delete:

The process can not access the file 'C:\Documents and Settings\TREVORXPS\ASPNET\LOCALS~1\Temp\tmpA3.tmp' because it is being used by another process.

how do i solve this?

thanks - Trevor
Question by:trevorhartman
LVL 33

Accepted Solution

raterus earned 1200 total points
ID: 13913121
Trevor, it looks like you are doing everything correct.  As you probably know, you get errors like this when you don't close open streams to the file.  No other code touches that file before the deletion?  If you can't determine the source, head over here http://www.sysinternals.com/ntw2k/freeware/procexp.shtml, and get this utility.  You can use it to see which process has the file open (likely aspnet_wp.exe)
LVL 15

Assisted Solution

praneetha earned 800 total points
ID: 13913155
i had the same problem once..and restarting it fixed it..

Author Comment

ID: 13937371
hmm, works now, thanks :)

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

575 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question