diddom 发表于 2012-6-6 05:33:04

Read before check the file size


说明

范例指令档示范如何使用 FileSystemObject 在尝试读取一个文字档前,确保档案内容不是空的。本范例指令档必需在本机执行。

范例指令码

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Windows\Netlogon.log")
If objFile.Size > 0 Then
    Set objReadFile = objFSO.OpenTextFile("C:\Windows\Netlogon.log", 1)
    strContents = objReadFile.ReadAll
    Wscript.Echo strContents
    objReadFile.Close
Else
    Wscript.Echo "The file is empty."
End If

页: [1]
查看完整版本: Read before check the file size