使用fso修改文件特定内容的函数
functionfsochange(ファイル名、ターゲット、文字列)
dimobjfso、objcountfile、filetempdata
setobjfso = server.createObject( "Scripting.filesystemObject")
setobjcountfile = objfso.opentextfile(server.mappath(filename)、1、true)
filetempdata = objcountfile.readall
objcountfile.close
filetempdata =置換(filetempdata、ターゲット、文字列)
setobjcountfile = objfso.createTextfile(server.mappath(filename)、true)
objcountfile.writefiletempdata
objcountfile.close
setobjcountfile = Nothing
setobjfso =何もない
エンド機能
使用fso读取文件内容的函数
functionfsofileread(filename)
dimobjfso、objcountfile、filetempdata
setobjfso = server.createObject( "Scripting.filesystemObject")
setobjcountfile = objfso.opentextfile(server.mappath(filename)、1、true)
fsofileread = objcountfile.readall
objcountfile.close
setobjcountfile = Nothing
setobjfso =何もない
エンド機能
使用fso读取文件某一行的函数
functionfsolinedit(filename、linenum)
iflinenum <1thenexitfunction
dimfso、f、temparray、tempcnt
setFSO = server.createObject( "Scripting.filesystemObject")
ifnotfso.fileexists(server.mappath(filename))thenexitfunction
setf = fso.opentextfile(server.mappath(filename)、1)
ifnotf.atendofstreamthen
tempcnt = f.readall
f.close
setf = Nothing
temparray = split(tempcnt、chr(13)&chr(10))
iflinenum> ubound(temparray)+1then
exitFunction
それ以外
fsolinedit = temparray(linenum-1)
endif
endif
エンド機能
使用fso写文件某一行的函数
functionfsolinewrite(filename、linenum、linecontent)
iflinenum <1thenexitfunction
dimfso、f、temparray、tempcnt
setFSO = server.createObject( "Scripting.filesystemObject")
ifnotfso.fileexists(server.mappath(filename))thenexitfunction
setf = fso.opentextfile(server.mappath(filename)、1)
ifnotf.atendofstreamthen
tempcnt = f.readall
f.close
temparray = split(tempcnt、chr(13)&chr(10))
iflinenum> ubound(temparray)+1then
exitFunction
それ以外
Temparray(linenum-1)= linecontent