<
%
function FSOlinedit(filename,starNum,endnum)
if starNum < 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 starNum > ubound (temparray) + 1 then
exit function
else
i = starNum
for j = i to endnum
a = a & temparray(j - 1 ) & " , "
next
FSOlinedit = a
end if
end if
end function
b = split (FSOlinedit( " test.txt " , 5 , 8 ) , " , " )
for i = 0 to 4
response.Write b(i) & " "
next
% >
function FSOlinedit(filename,starNum,endnum)
if starNum < 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 starNum > ubound (temparray) + 1 then
exit function
else
i = starNum
for j = i to endnum
a = a & temparray(j - 1 ) & " , "
next
FSOlinedit = a
end if
end if
end function
b = split (FSOlinedit( " test.txt " , 5 , 8 ) , " , " )
for i = 0 to 4
response.Write b(i) & " "
next
% >
主要使用了FSO的Readall方法用于返回整个文件的内容,并用temparray = split(tempcnt,chr(13)&chr(10))
拆分赋给新的数组
然后利用循环读取指定的行数