Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27459

VS 2010 streamwriter inside a for loop

$
0
0
i have a streamwriter inside of a for loop so that for each file that is moved the file name is written out to a log. it's working but it's only saving the last file that is moved to the file. am i missing something?


Code:

Dim sr As StreamWriter = New StreamWriter("C:\log.txt")
For Each item As Object In lb_M3test.Items
                        If item.ToString = code Then
                            File.Copy(f, destFile)
                            sr.WriteLine(DateTime.Now.ToString & "  " & fileName)
                            sr.Close()
                            fileCount = fileCount + 1
                        End If
                    Next


Viewing all articles
Browse latest Browse all 27459

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>