使用 FSO 修改文件特定内容的函数
functionfsochange (nom de fichier, cible, chaîne)
Dimobjfso, objCountFile, filempdata
SetObjfso = server.createObject ("scripting.fileSystemObject")
SetObjCountFile = objfso.OpenTExtFile (server.mappath (nom de fichier), 1, true)
FilempData = objCountFile.readall
objCountFile.close
FilempData = remplacer (filempdata, cible, chaîne)
SetObjCountFile = objfso.CreateTextFile (server.mappath (nom de fichier), true)
objCountFile.WriteFilempdata
objCountFile.close
SetObjCountFile = rien
SetObjfso = rien
Finition de fin
使用 FSO 读取文件内容的函数
functionfsofileread (nom de fichier)
Dimobjfso, objCountFile, filempdata
SetObjfso = server.createObject ("scripting.fileSystemObject")
SetObjCountFile = objfso.OpenTExtFile (server.mappath (nom de fichier), 1, true)
FsoFileRead = objCountFile.readall
objCountFile.close
SetObjCountFile = rien
SetObjfso = rien
Finition de fin
使用 FSO 读取文件某一行的函数
functionfsolinedit (nom de fichier, linem)
iflinenum <1Thenexitfunction
dimfso, f, temparray, tempcnt
setfso = server.createObject ("scripting.filesystemObject")
ifnotfso.fileexists (server.mappath (nom de fichier)) alorsxitfunction
setf = fso.OpenTExtFile (server.mappath (nom de fichier), 1)
ifnotf.atendofstreamhen
tempcnt = f.readall
f.close
setf = rien
Temparray = Split (Tempcnt, Chr (13) & Chr (10))
iflineNum> Ubound (temparray) + 1Then
sortie
autre
Fsolinedit = temparray (linenum-1)
endire
endire
finition de fin
使用 FSO 写文件某一行的函数
FONCTIONFSOLINEWRITE (nom de fichier, linénum, lineContent)
iflinenum <1Thenexitfunction
dimfso, f, temparray, tempcnt
setfso = server.createObject ("scripting.filesystemObject")
ifnotfso.fileexists (server.mappath (nom de fichier)) alorsxitfunction
setf = fso.OpenTExtFile (server.mappath (nom de fichier), 1)
ifnotf.atendofstreamhen
tempcnt = f.readall
f.close
Temparray = Split (Tempcnt, Chr (13) & Chr (10))
iflineNum> Ubound (temparray) + 1Then
sortie
autre
temparray (linenum-1) = lineContent