**************************************************
'函數(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
新聞熱點(diǎn)
疑難解答
圖片精選