使用FSO修改文件某一行的函数
function FSOlinewrite(filename,lineNum,Linecontent) if linenum < 1 then exit function dim fso,f,temparray,tempCnt set fso = server.CreateObject("scripting.filesystemobject") if not fso.fileExists(server.mappath(filename)) then exit function set f = fso.opentextfile(server.mappath(filename),1) if not f.AtEndofStream then tempcnt = f.readall f.close temparray = split(tempcnt,chr(13)&chr(10)) if lineNum>ubound(temparray)+1 then exit function else temparray(lineNum-1) = lineContent end if tempcnt = join(temparray,chr(13)&chr(10)) set f = fso.createtextfile(server.mappath(filename),true) f.write tempcnt end if f.close set f = nothing end function
|