Tengo esta instruccion:
My.Computer.FileSystem.DeleteFile("config\temp\tem p4.ini")
Necesito borrar algunos archivos que se hacen mientras la aplicacion esta en ejecucion, pero cuando se cierra, me da un error diciendo lo siguiente:

No entiendo por que me sale el error, incluso tengo una instruccion previa a esa donde dice:
FileOpen(1, "config\temp\temp4.ini", OpenMode.Output)
Print(1, textbox1.text)
FileClose(1)
Lo mas extraño es que si tengo un temp1 y temp2 que si me los elimina
Aca les muestro todo el codigo que en pocas palabras cambia un texto plano en uno para lectura con "GetPrivateProfileSection"
Código PHP:
Module generafile
Friend Sub funcion_archivo()
reemplazar()
convertir()
End Sub
<Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True)> _
Private Function GetPrivateProfileSection(ByVal lpAppName As String, _
ByVal lpReturnedString As IntPtr, _
ByVal nSize As Integer, _
ByVal lpFileName As String) As Short
End Function
Private Sub convertir()
Dim variable As String
Dim FILE_NAME As String = "config\temp\temp4.ini"
Dim TextLine As String
Dim sLinea As String = ""
FILE_NAME.Trim(" ")
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
sLinea = objReader.ReadLine()
If Not sLinea.StartsWith("%") Then
TextLine = TextLine & sLinea & vbNewLine
End If
Loop
variable = Replace(TextLine, "]*", "* ")
TextLine = Replace(variable, "?", " ")
Else
MsgBox("File Does Not Exist")
End If
FileClose(1)
FileOpen(1, "config\temp\comments.ini", OpenMode.Output)
Print(1, TextLine)
SetAttr("config\temp\comments.ini", vbHidden)
FileClose(1)
End Sub
Private Sub reemplazar()
Dim cadena As String
Dim ip2 As IntPtr = Runtime.InteropServices.Marshal.AllocHGlobal(100000)
Dim sb2 As New System.Text.StringBuilder(100000)
Dim bt2 As Integer = GetPrivateProfileSection("Location", ip2, 100000, "config\verify.conf")
For j As Integer = 0 To bt2 - 1
sb2.Append(Convert.ToChar(Runtime.InteropServices.Marshal.ReadByte(ip2, j)))
Next
sb2.Remove(sb2.Length - 1, 1)
For Each line As String In sb2.ToString().Split(Convert.ToChar(0))
cadena = line
Next
FileClose(0)
Dim FILE_NAME As String = cadena
Dim TextLine As String
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine & vbNewLine
Loop
Else
MsgBox("File Does Not Exist")
End If
FileClose(1)
Dim variable As String
Dim variable2 As String
variable = Replace(TextLine, (""""), "")
variable2 = Replace(variable, ("[level_2]" & vbCrLf & "data="), "")
variable = Replace(variable2, ("[level_1]" & vbCrLf & "caption="), "[")
variable2 = (Replace(variable, ("[level_2]" & vbCrLf & "caption="), "="))
variable = Replace(variable2, (vbCrLf & "[level_3] "), "+")
variable2 = Replace(variable, (vbCrLf & "[level_3]"), "+")
FileOpen(1, "config\temp\temp1.ini", OpenMode.Output)
Print(1, variable2)
FileClose(1)
corchete()
End Sub
Private Sub corchete()
Dim FILE_NAME As String = "config\temp\temp1.ini"
Dim corchet As String
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Dim sLinea As String = ""
Dim TextLine As String = ""
Do While objReader.Peek() <> -1
sLinea = objReader.ReadLine()
If sLinea.StartsWith("[") Then sLinea = sLinea & "]"
TextLine = TextLine & sLinea & vbNewLine
Loop
corchet = TextLine
End If
FileOpen(1, "config\temp\temp2.ini", OpenMode.Output)
Print(1, corchet)
FileClose(1)
convertir2()
End Sub
Private Sub convertir2()
Dim FILE_NAME As String = "config\temp\temp2.ini"
Dim TextLine As String
Dim sLinea As String = ""
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
sLinea = objReader.ReadLine()
If Not sLinea.EndsWith("+") Then
TextLine = TextLine & sLinea & vbNewLine
End If
Loop
End If
Dim variable As String
Dim variable2 As String
variable2 = Replace(TextLine, (vbCrLf & "caption="), "* ")
variable = Replace(variable2, ("data="), "* ")
variable2 = Replace(variable, ("="), "")
variable = Replace(variable2, (" ]" & vbCrLf & "*"), "]" & vbCrLf & "%")
variable2 = Replace(variable, ("]" & vbCrLf & "*"), "]" & vbCrLf & "%")
variable = Replace(variable2, ("[level_2]"), "")
FileOpen(1, "config\temp\temp4.ini", OpenMode.Output)
Print(1, variable)
FileClose(1)
End Sub
End Module