From: simonc on
I want to make a loop to read data from a succession of binary files
(filepaths of the files are in a string array).

If I create a new filestream and from that a new binary reader before the
start of the loop how can I redefine the filestream to look at a different
file each time I go through the loop?

Grateful for advice
From: Andrew Morton on
simonc wrote:
> I want to make a loop to read data from a succession of binary files
> (filepaths of the files are in a string array).
>
> If I create a new filestream and from that a new binary reader before
> the start of the loop how can I redefine the filestream to look at a
> different file each time I go through the loop?

You can make a new instance for each loop iteration:

For Each f In files
Using br = New BinaryReader(New FileStream(f, FileMode.Open))
' do something with br
End Using
Next

--
Andrew


From: simonc on
Thanks very much for this. I've never come across Using before.