Monday, March 12, 2012

What is the correct way to reuse objects

Dim DBTableUpdateTrackerFile As New BinaryWriter(File.Create(fileName))

I would like to use that to create 5 files...I'm just not sure of the next statements...

I've tried

DBTableUpdateTrackerFile As New BinaryWriter(File.Create(fileName))

but I keep getting this error...

Compiler Error Message: BC30454: Expression is not a method

Anyway, I thought that was allowed...but I guess not...so.

If anyone could help...I appreciate it.oh..... As should be =

It works that way... is that a correct way to reuse an object?
the following works for me:

 Dim filename As String = Server.MapPath("test/test1.dat")
Dim DBTableUpdateTrackerFile As New System.IO.BinaryWriter(System.IO.File.Create(filename))
DBTableUpdateTrackerFile.Close()

filename = Server.MapPath("test/test2.dat")
DBTableUpdateTrackerFile = New System.IO.BinaryWriter(System.IO.File.Create(filename))
DBTableUpdateTrackerFile.Close()

filename = Server.MapPath("test/test3.dat")
DBTableUpdateTrackerFile = New System.IO.BinaryWriter(System.IO.File.Create(filename))
DBTableUpdateTrackerFile.Close()

0 comments:

Post a Comment