asp读取文本内容

'**************************************************    
'函数名:FSOFileRead    
'作 用:使用FSO读取文件内容的函数    
'参 数:filename ----文件名称    
'返回值:文件内容    
'**************************************************    
function FSOFileRead(filename)    
Dim objFSO,objCountFile,FiletempData    
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")    
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)    
FSOFileRead = objCountFile.ReadAll    
objCountFile.Close    
Set objCountFile=Nothing    
Set objFSO = Nothing    
End Function    
  
'**************************************************    
'函数名:FSOlinedit    
'作 用:使用FSO读取文件某一行的函数    
'参 数:filename ----文件名称    
' lineNum ----行数    
'返回值:文件该行内容    
'**************************************************    
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    
  
'**************************************************    
'函数名:FSOlinewrite    
'作 用:使用FSO写文件某一行的函数    
'参 数:filename ----文件名称    
' lineNum ----行数    
' Linecontent ----内容    
'返回值:无    
'**************************************************    
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  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值