Hi

I try to delete system Temp file using this following method.

Public Sub DeleteTempFile()
Dim sTempFileName As String
For Each sTempFileName In Directory.GetFiles(GetTempDirectory())
System.IO.File.Delete(sTempFileName)
End Sub

Function GetTempDirectory() As String
Return Environment.GetEnvironmentVariable("TEMP")
End Function


But when i delete i get "IOException wad unhandled" error.

That error messge is: "The process cannot access the file 'C:\Documents and Settings\Administrator\Local Settings\Temp\29.tmp' because it is being used by another process."




Can anybody help me solution to solve this problem.
by
Yusuf