|
-
Nov 4th, 2011, 05:26 AM
#1
Thread Starter
Junior Member
VB Dynamic streamwriter name from a file
building another command-line app and I need to generate a log file and write to it throughout the app's run, but the log needs to be named <work_order>_<device>.log - both of those are held in a text file and will change frequently.
I can extract them no problem, and use them in the log file, but can't get the log file to use them in the name.
so I have:
Code:
Using strDATA As New StreamReader(DATA_FILE)
Do While Not strDATA.EndOfStream
Dim eng As String() = Split(strDATA.ReadLine, "=")
Select Case eng(0)
Case "DEV" : DEVICE = eng(1)
Case "WOID" : WORK_ORDER = eng(1)
Case(...lots of other junk...)
Case Else
End Select
Loop
LOG = PATH & WORK_ORDER & "_" & DEVICE & ".log"
TMP = PATH & WORK_ORDER & "_" & DEVICE & ".tmp"
CSV = PATH & WORK_ORDER & "_" & DEVICE & ".csv"
Static swMergeLog As StreamWriter = New StreamWriter(LOG)
' WRITE LOG FILE HEADERS INTO NEW LOG:
swMergeLog.WriteLine(vbCrLf & _
"=====================================" & vbCrLf & _
"WORK ORDER: " & WORK_ORDER & vbCrLf & _
"DEVICE NO: " & DEVICE & vbCrLf & _
"=====================================" & vbCrLf)
End Using
PATH and WORK_ORDER are declared as Public earlier on as are PATH, LOG, TMP and CSV, this sub is also Public. I also need to use the log writer in other subs as well as WORK_ORDER and DEVICE. Using Static doesn't work, so I'm a bit stumped. Can anyone assist?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|