vbscript如何检查txt文件是否存在以及何时不创建空文件
如何使用vbscript检查C:\Temp\CAD\u Kunde.txt中的txt文件是否存在,如果不存在,则应将其创建为空 编辑: 当我使用此命令时,我在第11行Char 1上得到一个错误(预期语句):vbscript如何检查txt文件是否存在以及何时不创建空文件,vbscript,hta,Vbscript,Hta,如何使用vbscript检查C:\Temp\CAD\u Kunde.txt中的txt文件是否存在,如果不存在,则应将其创建为空 编辑: 当我使用此命令时,我在第11行Char 1上得到一个错误(预期语句): <SCRIPT Language="VBScript"> Sub Window_OnLoad //Line 11 is the one below: Option Explicit Dim oFSO, oTxtFile
<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>
子窗口加载
//第11行如下:
选项显式
光的暗度,oTxtFile
Set of so=CreateObject(“Scripting.FileSystemObject”)
如果存在oFSO.FILE(“C:\Temp\CAD\u Kunde.txt”),则
Msgbox“文件存在”
其他的
设置oTxtFile=oFSO.CreateTextFile(“C:\Temp\CAD\u Kunde.txt”)
Msgbox“已创建文件”
如果结束
端接头
很简单
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
很容易
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
子窗口加载
选项显式
Dim oTxtFile
使用(CreateObject(“Scripting.FileSystemObject”))
如果.files存在(“C:\Temp\CAD\u Kunde.txt”),则
Msgbox“文件存在”
其他的
设置oTxtFile=.CreateTextFile(“C:\Temp\CAD\u Kunde.txt”)
Msgbox“已创建文件”
如果结束
以
端接头
子窗口加载
选项显式
Dim oTxtFile
使用(CreateObject(“Scripting.FileSystemObject”))
如果.files存在(“C:\Temp\CAD\u Kunde.txt”),则
Msgbox“文件存在”
其他的
设置oTxtFile=.CreateTextFile(“C:\Temp\CAD\u Kunde.txt”)
Msgbox“已创建文件”
如果结束
以
端接头
如果您不在乎区分存在与不存在,只想确保存在一个,您可以
set f = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\blabla", 1, true)
f.close()
如果你不在乎区分存在与不存在,只想确保存在一个,你可以
set f = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\blabla", 1, true)
f.close()
将选项显式行置于子行之前。将选项显式行置于子行之前。