asp OpenTextFile文本读取与写入实例代码(2)
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\jb51\index2.htm") flsize2=fn2.size fldate2=fn2.datelastmodified set fn=fso.GetFile("E:\webroot\jb51\index.htm") flsize1=fn.size fldate1=fn.datelastmodified If fso.FileExists("E:\webroot\jb51\index2.htm") and flsize2>50000 and fldate2>fldate1 Then '判断文件的大小,如果html文件重新生成需要判断是否更新过且文件不能小于50K fso.getfile("E:\webroot\jb51\index2.htm").copy("E:\webroot\jb51\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