家园首页 Php4手册 我的相册 家园下载 个人文集 给我留言
我形我塑,网络相册,www.5x54.com 相册 相册 心情相册,少女相册 免费申请,我形我塑免费相册
 家园 个人文集   http://www.5x54.com
 


FSO操作文本的几个函数


作者:网上收集    点击: 读取中...

使用FSO修改文件特定内容的函数 (%$$#^71367*&%2)我型我塑www.5x54.com
function FSOchange(filename,Target,String) (%$$#^71367*&%2)我型我塑www.5x54.com
Dim objFSO,objCountFile,FiletempData (%$$#^71367*&%2)我型我塑www.5x54.com
Set objFSO = Server.CreateObject("Scripting.FileSystemObject") (%$$#^71367*&%2)我型我塑www.5x54.com
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True) (%$$#^71367*&%2)我型我塑www.5x54.com
FiletempData = objCountFile.ReadAll (%$$#^71367*&%2)我型我塑www.5x54.com
objCountFile.Close (%$$#^71367*&%2)我型我塑www.5x54.com
FiletempData=Replace(FiletempData,Target,String) (%$$#^71367*&%2)我型我塑www.5x54.com
Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True) (%$$#^71367*&%2)我型我塑www.5x54.com
objCountFile.Write FiletempData  (%$$#^71367*&%2)我型我塑www.5x54.com
objCountFile.Close (%$$#^71367*&%2)我型我塑www.5x54.com
Set objCountFile=Nothing (%$$#^71367*&%2)我型我塑www.5x54.com
Set objFSO = Nothing (%$$#^71367*&%2)我型我塑www.5x54.com
End Function (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
使用FSO读取文件内容的函数 (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
function FSOFileRead(filename)  (%$$#^71367*&%2)我型我塑www.5x54.com
Dim objFSO,objCountFile,FiletempData  (%$$#^71367*&%2)我型我塑www.5x54.com
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")  (%$$#^71367*&%2)我型我塑www.5x54.com
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)  (%$$#^71367*&%2)我型我塑www.5x54.com
FSOFileRead = objCountFile.ReadAll  (%$$#^71367*&%2)我型我塑www.5x54.com
objCountFile.Close  (%$$#^71367*&%2)我型我塑www.5x54.com
Set objCountFile=Nothing  (%$$#^71367*&%2)我型我塑www.5x54.com
Set objFSO = Nothing  (%$$#^71367*&%2)我型我塑www.5x54.com
End Function  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
使用FSO读取文件某一行的函数 (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
function FSOlinedit(filename,lineNum)  (%$$#^71367*&%2)我型我塑www.5x54.com
if linenum < 1 then exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
dim fso,f,temparray,tempcnt  (%$$#^71367*&%2)我型我塑www.5x54.com
set fso = server.CreateObject("scripting.filesystemobject")  (%$$#^71367*&%2)我型我塑www.5x54.com
if not fso.fileExists(server.mappath(filename)) then exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = fso.opentextfile(server.mappath(filename),1)  (%$$#^71367*&%2)我型我塑www.5x54.com
if not f.AtEndofStream then  (%$$#^71367*&%2)我型我塑www.5x54.com
tempcnt = f.readall  (%$$#^71367*&%2)我型我塑www.5x54.com
f.close  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = nothing  (%$$#^71367*&%2)我型我塑www.5x54.com
temparray = split(tempcnt,chr(13)&chr(10))  (%$$#^71367*&%2)我型我塑www.5x54.com
if lineNum>ubound(temparray)+1 then  (%$$#^71367*&%2)我型我塑www.5x54.com
 exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
else  (%$$#^71367*&%2)我型我塑www.5x54.com
 FSOlinedit = temparray(lineNum-1)  (%$$#^71367*&%2)我型我塑www.5x54.com
end if  (%$$#^71367*&%2)我型我塑www.5x54.com
end if  (%$$#^71367*&%2)我型我塑www.5x54.com
end function  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
使用FSO写文件某一行的函数 (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
function FSOlinewrite(filename,lineNum,Linecontent)  (%$$#^71367*&%2)我型我塑www.5x54.com
if linenum < 1 then exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
dim fso,f,temparray,tempCnt  (%$$#^71367*&%2)我型我塑www.5x54.com
set fso = server.CreateObject("scripting.filesystemobject")  (%$$#^71367*&%2)我型我塑www.5x54.com
if not fso.fileExists(server.mappath(filename)) then exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = fso.opentextfile(server.mappath(filename),1)  (%$$#^71367*&%2)我型我塑www.5x54.com
if not f.AtEndofStream then  (%$$#^71367*&%2)我型我塑www.5x54.com
tempcnt = f.readall  (%$$#^71367*&%2)我型我塑www.5x54.com
f.close  (%$$#^71367*&%2)我型我塑www.5x54.com
temparray = split(tempcnt,chr(13)&chr(10))  (%$$#^71367*&%2)我型我塑www.5x54.com
if lineNum>ubound(temparray)+1 then  (%$$#^71367*&%2)我型我塑www.5x54.com
 exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
else  (%$$#^71367*&%2)我型我塑www.5x54.com
 temparray(lineNum-1) = lineContent  (%$$#^71367*&%2)我型我塑www.5x54.com
end if  (%$$#^71367*&%2)我型我塑www.5x54.com
tempcnt = join(temparray,chr(13)&chr(10))  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = fso.createtextfile(server.mappath(filename),true)  (%$$#^71367*&%2)我型我塑www.5x54.com
f.write tempcnt  (%$$#^71367*&%2)我型我塑www.5x54.com
end if  (%$$#^71367*&%2)我型我塑www.5x54.com
f.close  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = nothing  (%$$#^71367*&%2)我型我塑www.5x54.com
end function  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
使用FSO添加文件新行的函数 (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
function FSOappline(filename,Linecontent)  (%$$#^71367*&%2)我型我塑www.5x54.com
dim fso,f  (%$$#^71367*&%2)我型我塑www.5x54.com
set fso = server.CreateObject("scripting.filesystemobject")  (%$$#^71367*&%2)我型我塑www.5x54.com
if not fso.fileExists(server.mappath(filename)) then exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = fso.opentextfile(server.mappath(filename),8,1)  (%$$#^71367*&%2)我型我塑www.5x54.com
f.write chr(13)&chr(10)&Linecontent  (%$$#^71367*&%2)我型我塑www.5x54.com
f.close  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = nothing  (%$$#^71367*&%2)我型我塑www.5x54.com
end function  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
  (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
读文件最后一行的函数 (%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
(%$$#^71367*&%2)我型我塑www.5x54.com
function FSOlastline(filename)  (%$$#^71367*&%2)我型我塑www.5x54.com
dim fso,f,temparray,tempcnt  (%$$#^71367*&%2)我型我塑www.5x54.com
set fso = server.CreateObject("scripting.filesystemobject")  (%$$#^71367*&%2)我型我塑www.5x54.com
if not fso.fileExists(server.mappath(filename)) then exit function  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = fso.opentextfile(server.mappath(filename),1)  (%$$#^71367*&%2)我型我塑www.5x54.com
if not f.AtEndofStream then  (%$$#^71367*&%2)我型我塑www.5x54.com
tempcnt = f.readall  (%$$#^71367*&%2)我型我塑www.5x54.com
f.close  (%$$#^71367*&%2)我型我塑www.5x54.com
set f = nothing  (%$$#^71367*&%2)我型我塑www.5x54.com
temparray = split(tempcnt,chr(13)&chr(10))  (%$$#^71367*&%2)我型我塑www.5x54.com
 FSOlastline = temparray(ubound(temparray))  (%$$#^71367*&%2)我型我塑www.5x54.com
end if  (%$$#^71367*&%2)我型我塑www.5x54.com
end function  (%$$#^71367*&%2)我型我塑www.5x54.com

收藏此文章     打印  更新     编辑此文章    『关闭窗口』