15 pts.
 How do I delete a file that I created at run time when my program closes? VB.NET
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:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _