asp的幾個fso  相關的函數

| |
[不指定 2007/12/31 09:56 | by ]
'**************************************************
'函数名: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

作者:Else 's Blog
地址:http://www.aixq.com/post/898/
版权所有。转载时必须链接形式注明作者和原始出处及本声明!
  • 中查看更多“asp的幾個fso  相關的函數”相关内容
  • 中查看更多“asp的幾個fso  相關的函數”相关内容
  • 中查看更多“asp的幾個fso  相關的函數”相关内容
  • 中查看更多“asp的幾個fso  相關的函數”相关内容
  • 中查看更多“asp的幾個fso  相關的函數”相关内容
  • 中查看更多“asp的幾個fso  相關的函數”相关内容

  • 最后编辑: Else 编辑于2008/01/03 12:36
    代码 程序 编程 | 评论(0) | 引用(0) | 阅读(602)
    发表评论
    表情
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    emotemotemotemotemot
    打开HTML
    打开UBB
    打开表情
    隐藏
    昵称   密码   游客无需密码
    网址   电邮   [注册]