在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
object.OpenTextFile(filename[, iomode[, create[, format]]]) 复制代码 代码如下: Sub OpenTextFileTest Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True) f.Write "嗨,你好!" f.Close End Sub 极客世界写的一个判断文件是否被更改过的代码 Dim fso Set fso = CreateObject("Scripting.FileSystemObject") set fn2=fso.GetFile("E:\webroot\ogeek\index2.htm") flsize2=fn2.size fldate2=fn2.datelastmodified set fn=fso.GetFile("E:\webroot\ogeek\index.htm") flsize1=fn.size fldate1=fn.datelastmodified If fso.FileExists("E:\webroot\ogeek\index2.htm") and flsize2>50000 and fldate2>fldate1 Then '判断文件的大小,如果html文件重新生成需要判断是否更新过且文件不能小于50K fso.getfile("E:\webroot\ogeek\index2.htm").copy("E:\webroot\ogeek\index.htm") if err.number=0 then WriteHistory "成功"&now()&".........","log.txt" end if '日志写入函数 Sub WriteHistory(hisChars, path) Const ForReading = 1, ForAppending = 8 Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(path, ForAppending, True) f.WriteLine hisChars f.Close End Sub |
请发表评论