Yeah...that really answered my question
I'm guessing it is the delete. I removed the DB code and put in a using to eliminate the dispose. My guess is something really does have the file. When does it occur? When you are running tests over and over again? When users are running it? The basic loop seems good to me.
Code:Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim dirinfo As DirectoryInfo Dim allFiles() As FileInfo dirinfo = New DirectoryInfo("C:\CAC") allFiles = dirinfo.GetFiles("*.xlsx") If allFiles.Length <> 0 Then Try For Each fl As FileInfo In allFiles Using sr As StreamReader = New StreamReader(fl.FullName) Dim line As String = sr.ReadLine Dim value() As String = line.Split(Microsoft.VisualBasic.ChrW(44)) sr.Close() System.IO.File.Delete(fl.FullName) End Using Next Catch ex As Exception MsgBox(ex.Message) End Try End If End Sub





Reply With Quote
