国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 建水县| 碌曲县| 宣威市| 姜堰市| 湖南省| 云霄县| 郸城县| 潜山县| 蕲春县| 连平县| 合肥市| 鹿泉市| 永川市| 灵宝市| 团风县| 呼玛县| 密山市| 运城市| 麻阳| 余庆县| 商都县| 涞水县| 伊宁县| 乐安县| 特克斯县| 循化| 河间市| 松潘县| 太白县| 福建省| 北京市| 柳林县| 建阳市| 绥化市| 淳安县| 土默特右旗| 乐陵市| 健康| 丽水市| 合江县| 寻甸|