【发布时间】:2012-02-27 12:48:09
【问题描述】:
如何使用 vbscript 检查 C:\Temp\CAD_Kunde.txt 中的 txt 文件是否存在,如果不存在,则应为空创建。
编辑: 我收到一个错误(当我使用这个时,第 11 行字符 1 上的预期语句:
<SCRIPT Language="VBScript">
Sub Window_OnLoad
//Line 11 is the one below:
Option Explicit
Dim oFSO, oTxtFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists("C:\Temp\CAD_Kunde.txt") then
Msgbox "File Exist"
Else
Set oTxtFile = oFSO.CreateTextFile("C:\Temp\CAD_Kunde.txt")
Msgbox "File Created"
End If
End Sub
</script>
【问题讨论】:
-
将 Option 显式行放在子行之前。