分类
“使用fso写文件某一行的函数”的ASP编程代码是:
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
。