国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

用ASP讀取文本文件的幾個(gè)函數(shù)

2024-05-04 11:07:26
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

**************************************************
'函數(shù)名:FSOFileRead
'作 用:使用FSO讀取文件內(nèi)容的函數(shù)
'參 數(shù):filename ----文件名稱
'返回值:文件內(nèi)容
'**************************************************
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

'**************************************************
'函數(shù)名:FSOlinedit
'作 用:使用FSO讀取文件某一行的函數(shù)
'參 數(shù):filename ----文件名稱
' lineNum ----行數(shù)
'返回值:文件該行內(nèi)容
'**************************************************
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

'**************************************************
'函數(shù)名:FSOlinewrite
'作 用:使用FSO寫文件某一行的函數(shù)
'參 數(shù):filename ----文件名稱
' lineNum ----行數(shù)
' Linecontent ----內(nèi)容
'返回值:無(wú)
'**************************************************
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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 新蔡县| 广元市| 延安市| 甘孜| 隆林| 安阳市| 龙江县| 孟州市| 雅安市| 延庆县| 新竹县| 安康市| 承德县| 台湾省| 文水县| 历史| 府谷县| 长武县| 大关县| 和田市| 白山市| 汾西县| 巴楚县| 海城市| 囊谦县| 监利县| 汪清县| 绥中县| 玉溪市| 宁河县| 德安县| 乌海市| 基隆市| 犍为县| 九寨沟县| 永昌县| 杨浦区| 监利县| 监利县| 华容县| 石棉县|