http://www.4guysfromrolla.com/webtech/010401-1.shtml
const ForReading = 1 const TristateFalse = 0 dim strSearchThis dim objFS dim objFile dim objTS set objFS = Server.CreateObject("Scripting.FileSystemObject") set objFile = objFS.GetFile(Server.MapPath("myfile.txt")) set objTS = objFile.OpenAsTextStream(ForReading, TristateFalse) strSearchThis = objTS.Read(objFile.Size) if instr(strSearchThis, "keyword") > 0 then Response.Write "Found it!" end if
Writing UTF-8 files
http://abouttesting.blogspot.com/2008/04/vbscript-reading-text-files.html
Function getTextFileContent (strFileName, strCharSet)
Const adTypeBinary = 1 'not used
Const adTypeText = 2
'Set default CharSet
If strCharSet = "" Then strCharSet = "ASCII"
' *** CharSets ***
' Windows-1252
' Windows-1257
' UTF-16
' UTF-8
' UTF-7
' ASCII
' X-ANSI
' iso-8859-2
Set objStreamFile = CreateObject("Adodb.Stream")
With objStreamFile
.CharSet = strCharSet
.Type= adTypeText
.Open
.LoadFromFile strFileName
getTextFileContent = .readText
.Close
End With
Set objStreamFile = Nothing
End Function
No comments:
Post a Comment