“使用fso读取文件某一行的函数”的ASP编程代码是什么

renwenyishuadmin 提交于 周三, 2018/06/13 - 03:35
分类

“使用fso读取文件某一行的函数”的ASP编程代码是:

function fsolinedit(filename,linenum)

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

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

if linenum>ubound(temparray)+1 then

exit function

else

fsolinedit = temparray(linenum-1)

end if

end if

end function