如何确保 CSV 文件在 ASP Classic 打开前不为空?

How to ensure CSV file is not blank in ASP Classic before opening?

我在 ASP Classic 中打开非常大的 CSV 文件时遇到尚未创建的问题。代码如下。

csvFile.close()
Set csvFile = Nothing
Set fso = Nothing
Set fso = Server.CreateObject("Scripting.FileSystemObject")
strFileFullPath = fso.BuildPath(xRefCsvRoot, filename)
Set ts = fso.OpenTextFile(strFileFullPath, 1)

strFile = ts.ReadAll
ts.Close()

response.Clear()
response.AddHeader "content-disposition", "attachment; filename=" & filename
response.Write(strFile)
response.End()

有没有一种有效的方法可以在读取文件之前检查文件是否为空?

勾选 file size:

If fso.GetFile(strFileFullPath).Size > 0 Then
  'file is not empty
End If