How to force VB.Net GC to close file ?

Oct 2, 2013 at 11:28 AM
Edited Oct 2, 2013 at 12:07 PM
Hi,

I use this code for decompress many archives with SevenZipSharp library :
 Private Sub DecompressFile(ByVal FileToDecompress As FileInfo, ByVal ExtractDir As String)
        Dim Tmp As New SevenZipExtractor(FileToDecompress.FullName)
        Static tabSize As Integer = 0

        Try
            For i = 0 To Tmp.ArchiveFileData.Count - 1
                Tmp.ExtractFiles(ExtractDir, Tmp.ArchiveFileData(i).Index)

                '* Ajout du fichier courant à la liste des fichiers à importer et redimenssionnement du tableau.
                tabSize = tabSize + 1
                Array.Resize(FilesList, tabSize)
                FilesList(tabSize - 1) = ExtractDir & "\" & Tmp.ArchiveFileData(i).FileName
            Next

            If Not IsOnError Then
                '* Deplacement de l'archive originale dans le dossier decompresse.
                Try
                    Tmp.Dispose()
                    'File.Move(FileToDecompress.FullName, ExtractDir & "\" & FileToDecompress.Name)
                Catch ex As Exception
                    ErrorMessages = ErrorMessages & vbCrLf & ex.Message.ToString
                    IsOnError = True
                End Try
            End If
        Catch ex As Exception
            ErrorMessages = ErrorMessages & vbCrLf & ex.Message.ToString
            IsOnError = True
        End Try
    End Sub
With another personnal class, I try to open the decompressed files for parsing but Visual Studio say me that file is not closed !

How can I force to close these files ?

Thanks
Franck