<%
Function ReadTxtFile(FileName)
Dim fso,f1,ts,FilePath
FilePath=server.mappath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(FilePath,1,1)
ReadTxtFile = ts.ReadAll
set ts=nothing
set fso=nothing
End Function
function FSOchange(filename,Target,Stringt)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData = objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,Stringt)
Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)
objCountFile.Write FiletempData
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function
sns=ReadTxtFile("1.txt")'读取txt文件
txt=split(sns,chr(13))'读取每行
for i=0 to ubound(txt)
if instr(txt(i),"KEY=")>0 then Ttxt=cstr(replace(replace(trim(txt(i)),chr(10),""),"KEY=","")) '读取 “某些内容=指定的行或者指定的内容”
next
'替换。
FSOchange "1.txt","某些内容="&Ttxt,"某些内容=指定的内容"
%>
|