vbscript - TextStream object to copy file -
i have script connects oracle, runs query, , saves output csv. there easy way of make copy of file using existing textstream
object?
' execute query set objresultset = objconnect.execute(strsql) ' create filename save query strtimestamp = datepart("yyyy",date) & right("0" & datepart("m",date), 2) & _ right("0" & datepart("d",date), 2) & right("0" & hour(now), 2) & _ right("0" & minute(now), 2) & right("0" & second(now), 2) stroutputfilename = strtimestamp & ".csv" set objfso = createobject("scripting.filesystemobject") set objoutputfile = objfso.createtextfile(stroutputfilename, true) ' loop through each row of recordset , output jobcode download file objresultset.movefirst while not objresultset.eof objoutputfile.writeline (objresultset(0) & "," & objresultset(1)) objresultset.movenext loop
you sort-of copy file creating files in both locations , writing content both files simultaneously. other you'll have use copy
or copyfile
method. textstream
objects have methods manipulating content of file, not location.
Comments
Post a Comment