Hi,
I've a console application which writes to two log files in C:\Temp. These files have the date incorporated to allow a new file for each day. Currently I'm having a problem with using the files.
Each time around I declare a New instance of my class, it calls the fso.CreateTextFile method, passing in the name I want to use. See the code below:
I get an exception in the FindFiles function which says it can't create ActiveX objects. Not sure why this is?
With this in mind I changed the code with the understanding that each time I created my new instance of the class, if the file already existed, the overwrite parameter of CreateTextFile would default to false, meaning it wouldn't create a new file, but (I hoped) append to the existing one. Unfortunately it does create a new file.
The oLOGFILE and oSCREENLOG are both closed prior to any call to the class's New sub. The Help seems to indicate that what I thought about the overwrite is correct, but it's clearly not?
Cheers,
Dave
"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me
For all your testing needs: Forum1393
I've a console application which writes to two log files in C:\Temp. These files have the date incorporated to allow a new file for each day. Currently I'm having a problem with using the files.
Each time around I declare a New instance of my class, it calls the fso.CreateTextFile method, passing in the name I want to use. See the code below:
Code:
Public Sub New()
' To achieve best speed we use 2 screen iDELAYs. A longer one for login stage and a shorter one for running stage.
iLOGIN_iDELAY = 1000
iRUNNING_iDELAY = 500
iDELAY = iLOGIN_iDELAY
Dim dDateVals(3)
Dim dDateVal
dDateVal = System.DateTime.Today
dDateVals = Strings.Split(dDateVal, "/")
dDateVal = dDateVals(0) & dDateVals(1) & dDateVals(2)
Dim sFileName As String = "c:\temp\scms_log" & dDateVal & ".txt"
Dim sScreenFile As String = "c:\temp\scms_screen_log" & dDateVal & ".txt"
Dim bFoundLog = False
Dim bFoundScreen = False
oFSO = CreateObject("scripting.filesystemobject")
bFoundLog = FindFiles(sFileName)
bFoundScreen = FindFiles(sScreenFile)
If bFoundLog = False then
oLOGFILE = oFSO.CreateTextFile(sFileName)
oSCREENLOG = oFSO.CreateTextFile(sScreenFile)
End If
oEXTRA = CreateObject("EXTRA.System")
oSESSIONS = oEXTRA.Sessions
'Set oSESSION = oSESSIONS.Open("C:\Program Files\E!PC\Sessions\BACKDCMS.EDP")
If oSESSIONS.Count > 0 Then
oSESSION = oEXTRA.ActiveSession
oSCREEN = oSESSION.Screen
End If
End Sub
Public Function FindFile(ByVal sFileName)
Dim oFile As Object
oFile = CreateObject("Microsoft.VisualBasic.FileIO.FileSystem")
If oFile.FileExists(sFileName) Then
'found
FindFile = True
Else
'not found
FindFile = False
End If
End Function
I get an exception in the FindFiles function which says it can't create ActiveX objects. Not sure why this is?
With this in mind I changed the code with the understanding that each time I created my new instance of the class, if the file already existed, the overwrite parameter of CreateTextFile would default to false, meaning it wouldn't create a new file, but (I hoped) append to the existing one. Unfortunately it does create a new file.
The oLOGFILE and oSCREENLOG are both closed prior to any call to the class's New sub. The Help seems to indicate that what I thought about the overwrite is correct, but it's clearly not?
Cheers,
Dave
"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me
For all your testing needs: Forum1393