Is it possible to...save to different file

kns

New member
Joined
Mar 29, 2006
Messages
3
Programming Experience
3-5
Output to multiple files in VB.net, I'm not talking output to numerous different already created files but create and write to new files each time an output is produced as opposed to overwriting the data in the file?

:)
 
You can keep a counter and start by 5 for instance, first file you save 'output5.txt', next you increase counter to 6 and save 'output6.txt', and so on.
 
The program outputs a series of numbers automatically each time it runs at an interval.

The problem I'm facing is I hope to have an individual text file for each output produced by the program i.e. output1.text, output2.text etc then store these text files for future reference. Where as at the moment each output simply overwrites the one before it.

The route of the problem is that when you create a text file the brackets restrict the file name. e.g.

Dim outstream As StreamWriter = File.CreateText("output1.text")

As I was hoping of using a fairly basic method of simply using a variable for the file name. Is this possible also? So for instance have the date and time for each interval stored as the actual file name....or am I asking too much.

I'm a little lost when it comes to anything more than basic file output as you can probably tell.


Thanks for all the inputs so far, the timer sound an interesting solution :)

 
VB.NET:
[COLOR=#0000ff]Dim[/COLOR][SIZE=2] counter [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Integer = getCounterFromWhereverYouStoreYourSettings()[/SIZE]
counter += 1
[COLOR=#0000ff]Dim[/COLOR][SIZE=2] outstream [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] StreamWriter = File.CreateText("output" & counter.ToString & ".text")[/SIZE]
storeCounterToWhereverYouStoreYourSettings(counter)
 
Back
Top