使用FSO修改文件特定内容的函数
(%$$#^71367*&%2)我型我塑www.5x54.com function FSOchange(filename,Target,String)
(%$$#^71367*&%2)我型我塑www.5x54.com Dim objFSO,objCountFile,FiletempData
(%$$#^71367*&%2)我型我塑www.5x54.com Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
(%$$#^71367*&%2)我型我塑www.5x54.com Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
(%$$#^71367*&%2)我型我塑www.5x54.com FiletempData = objCountFile.ReadAll
(%$$#^71367*&%2)我型我塑www.5x54.com objCountFile.Close
(%$$#^71367*&%2)我型我塑www.5x54.com FiletempData=Replace(FiletempData,Target,String)
(%$$#^71367*&%2)我型我塑www.5x54.com Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)
(%$$#^71367*&%2)我型我塑www.5x54.com objCountFile.Write FiletempData
(%$$#^71367*&%2)我型我塑www.5x54.com objCountFile.Close
(%$$#^71367*&%2)我型我塑www.5x54.com Set objCountFile=Nothing
(%$$#^71367*&%2)我型我塑www.5x54.com Set objFSO = Nothing
(%$$#^71367*&%2)我型我塑www.5x54.com End Function
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com 使用FSO读取文件内容的函数
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com function FSOFileRead(filename)
(%$$#^71367*&%2)我型我塑www.5x54.com Dim objFSO,objCountFile,FiletempData
(%$$#^71367*&%2)我型我塑www.5x54.com Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
(%$$#^71367*&%2)我型我塑www.5x54.com Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
(%$$#^71367*&%2)我型我塑www.5x54.com FSOFileRead = objCountFile.ReadAll
(%$$#^71367*&%2)我型我塑www.5x54.com objCountFile.Close
(%$$#^71367*&%2)我型我塑www.5x54.com Set objCountFile=Nothing
(%$$#^71367*&%2)我型我塑www.5x54.com Set objFSO = Nothing
(%$$#^71367*&%2)我型我塑www.5x54.com End Function
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com 使用FSO读取文件某一行的函数
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com function FSOlinedit(filename,lineNum)
(%$$#^71367*&%2)我型我塑www.5x54.com if linenum < 1 then exit function
(%$$#^71367*&%2)我型我塑www.5x54.com dim fso,f,temparray,tempcnt
(%$$#^71367*&%2)我型我塑www.5x54.com set fso = server.CreateObject("scripting.filesystemobject")
(%$$#^71367*&%2)我型我塑www.5x54.com if not fso.fileExists(server.mappath(filename)) then exit function
(%$$#^71367*&%2)我型我塑www.5x54.com set f = fso.opentextfile(server.mappath(filename),1)
(%$$#^71367*&%2)我型我塑www.5x54.com if not f.AtEndofStream then
(%$$#^71367*&%2)我型我塑www.5x54.com tempcnt = f.readall
(%$$#^71367*&%2)我型我塑www.5x54.com f.close
(%$$#^71367*&%2)我型我塑www.5x54.com set f = nothing
(%$$#^71367*&%2)我型我塑www.5x54.com temparray = split(tempcnt,chr(13)&chr(10))
(%$$#^71367*&%2)我型我塑www.5x54.com if lineNum>ubound(temparray)+1 then
(%$$#^71367*&%2)我型我塑www.5x54.com exit function
(%$$#^71367*&%2)我型我塑www.5x54.com else
(%$$#^71367*&%2)我型我塑www.5x54.com FSOlinedit = temparray(lineNum-1)
(%$$#^71367*&%2)我型我塑www.5x54.com end if
(%$$#^71367*&%2)我型我塑www.5x54.com end if
(%$$#^71367*&%2)我型我塑www.5x54.com end function
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com 使用FSO写文件某一行的函数
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com function FSOlinewrite(filename,lineNum,Linecontent)
(%$$#^71367*&%2)我型我塑www.5x54.com if linenum < 1 then exit function
(%$$#^71367*&%2)我型我塑www.5x54.com dim fso,f,temparray,tempCnt
(%$$#^71367*&%2)我型我塑www.5x54.com set fso = server.CreateObject("scripting.filesystemobject")
(%$$#^71367*&%2)我型我塑www.5x54.com if not fso.fileExists(server.mappath(filename)) then exit function
(%$$#^71367*&%2)我型我塑www.5x54.com set f = fso.opentextfile(server.mappath(filename),1)
(%$$#^71367*&%2)我型我塑www.5x54.com if not f.AtEndofStream then
(%$$#^71367*&%2)我型我塑www.5x54.com tempcnt = f.readall
(%$$#^71367*&%2)我型我塑www.5x54.com f.close
(%$$#^71367*&%2)我型我塑www.5x54.com temparray = split(tempcnt,chr(13)&chr(10))
(%$$#^71367*&%2)我型我塑www.5x54.com if lineNum>ubound(temparray)+1 then
(%$$#^71367*&%2)我型我塑www.5x54.com exit function
(%$$#^71367*&%2)我型我塑www.5x54.com else
(%$$#^71367*&%2)我型我塑www.5x54.com temparray(lineNum-1) = lineContent
(%$$#^71367*&%2)我型我塑www.5x54.com end if
(%$$#^71367*&%2)我型我塑www.5x54.com tempcnt = join(temparray,chr(13)&chr(10))
(%$$#^71367*&%2)我型我塑www.5x54.com set f = fso.createtextfile(server.mappath(filename),true)
(%$$#^71367*&%2)我型我塑www.5x54.com f.write tempcnt
(%$$#^71367*&%2)我型我塑www.5x54.com end if
(%$$#^71367*&%2)我型我塑www.5x54.com f.close
(%$$#^71367*&%2)我型我塑www.5x54.com set f = nothing
(%$$#^71367*&%2)我型我塑www.5x54.com end function
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com 使用FSO添加文件新行的函数
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com function FSOappline(filename,Linecontent)
(%$$#^71367*&%2)我型我塑www.5x54.com dim fso,f
(%$$#^71367*&%2)我型我塑www.5x54.com set fso = server.CreateObject("scripting.filesystemobject")
(%$$#^71367*&%2)我型我塑www.5x54.com if not fso.fileExists(server.mappath(filename)) then exit function
(%$$#^71367*&%2)我型我塑www.5x54.com set f = fso.opentextfile(server.mappath(filename),8,1)
(%$$#^71367*&%2)我型我塑www.5x54.com f.write chr(13)&chr(10)&Linecontent
(%$$#^71367*&%2)我型我塑www.5x54.com f.close
(%$$#^71367*&%2)我型我塑www.5x54.com set f = nothing
(%$$#^71367*&%2)我型我塑www.5x54.com end function
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com 读文件最后一行的函数
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com function FSOlastline(filename)
(%$$#^71367*&%2)我型我塑www.5x54.com dim fso,f,temparray,tempcnt
(%$$#^71367*&%2)我型我塑www.5x54.com set fso = server.CreateObject("scripting.filesystemobject")
(%$$#^71367*&%2)我型我塑www.5x54.com if not fso.fileExists(server.mappath(filename)) then exit function
(%$$#^71367*&%2)我型我塑www.5x54.com set f = fso.opentextfile(server.mappath(filename),1)
(%$$#^71367*&%2)我型我塑www.5x54.com if not f.AtEndofStream then
(%$$#^71367*&%2)我型我塑www.5x54.com tempcnt = f.readall
(%$$#^71367*&%2)我型我塑www.5x54.com f.close
(%$$#^71367*&%2)我型我塑www.5x54.com set f = nothing
(%$$#^71367*&%2)我型我塑www.5x54.com temparray = split(tempcnt,chr(13)&chr(10))
(%$$#^71367*&%2)我型我塑www.5x54.com FSOlastline = temparray(ubound(temparray))
(%$$#^71367*&%2)我型我塑www.5x54.com end if
(%$$#^71367*&%2)我型我塑www.5x54.com end function
(%$$#^71367*&%2)我型我塑www.5x54.com
|