0

我有一个 .csv 文件,其中一行不断被来自某些数据总线的最新数据覆盖。它看起来像这样:

Doors
Closed, Open, Closed, Closed,

它正在更新(让我们说每秒一次),因此一旦阀门发生变化,它就会显示在 csv 文件中,如下所示:

Doors
Closed, Closed, Closed, Closed,

如果我有一个当前正在读取信息行的 vbscript,我会通过尝试访问所述文件而收到错误吗?这几乎是我这部分的代码:

    'Create the file system object
Set fso = CreateObject("Scripting.FileSystemObject")

'Initialize a few items
strSource = "C:\Test.csv"

'Open the source file to read it
Set inputFile = fso.OpenTextFile(strSource,ForReading)

'Skip the first line since it is the heading
strLine = inputFile.ReadLine

'Read the file line by line
Do while not inputFile.AtEndOfStream
    strLine = inputFile.ReadLine

    'Split the line on the comma into an array
    strValues = Split(strLine, ",")

该代码适用于当前未使用的 .csv 文件,但我想知道如果我正在访问的文件不断更新,这是否会引发错误(即使我只是在阅读它)。

谢谢

4

0 回答 0