How do I delete a file that I created at run time when my program closes? VB.NET

15 pts.
Tags:
File management
Visual Basic 2008
Visual Basic 2008 Express
Windows 7
I'm using vb 2008 express, during runtime, a temporary file is created and used, but I'd like my application to delete all the temp files when it closes, I've tried using:
            System.IO.File.Delete("TempFile" & i.ToString)
but it keeps telling me access is denied.  How can I fix this?
The files are created like this:
        Using fs As New System.IO.FileStream("TempFile" & intTotal.ToString, IO.FileMode.Create)
            fs.Write(FontResource, 0, FontResource.Length)
        End Using
And then are loaded in the program like this:
        'Use the resulting File as a font
        pfc.AddFontFile("TempFile" & intTotal.ToString)
        Return New Font(pfc.Families(FontIndex), intFontSize(FontIndex), fsStyle(FontIndex))
When I run the program again, it loads the same content that was created previously and doesn't allow me to change it, which is why I need to delete them when the program closes.
Thanks.


Software/Hardware used:
WIndows 7, Visual Basic 2008 Express
ASKED: June 7, 2010  8:34 AM
UPDATED: June 7, 2010  1:42 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following