Public Function ReadLine(ByVal FileName As String, ByVal FileLine As Integer) As String Dim I As Integer, Fn As Integer, Str Fn = FreeFile Open FileName For Input As Fn I = 1 Do Until EOF(Fn) Line Input #Fn, Str If I = FileLine Then ReadLine = Str Exit Do End If I = I + 1 Loop Close Fn End Function
可以利用fso: 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 虽然有些asp的代码,但是稍加修改就行
Dim I As Integer, Fn As Integer, Str
Fn = FreeFile
Open FileName For Input As Fn
I = 1
Do Until EOF(Fn)
Line Input #Fn, Str
If I = FileLine Then
ReadLine = Str
Exit Do
End If
I = I + 1
Loop
Close Fn
End Function
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
虽然有些asp的代码,但是稍加修改就行