使用 fso 修改文件特定内容的函数
functionfsochange (ชื่อไฟล์, เป้าหมาย, สตริง)
dimobjfso, objcountfile, fileTempData
setObjfso = server.createObject ("scripting.filesystemobject")
setObjcountFile = objfso.opentextfile (server.mappath (ชื่อไฟล์), 1, true)
fileTempData = objcountfile.readall
objcountfile.close
fileTempData = แทนที่ (fileTempData, เป้าหมาย, สตริง)
setObjcountFile = objfso.createTextFile (Server.Mappath (ชื่อไฟล์), จริง)
objcountfile.writefileTempdata
objcountfile.close
setObjcountFile = ไม่มีอะไร
setObjfso = ไม่มีอะไร
endfunction
使用 fso 读取文件内容的函数
functionfsofileread (ชื่อไฟล์)
dimobjfso, objcountfile, fileTempData
setObjfso = server.createObject ("scripting.filesystemobject")
setObjcountFile = objfso.opentextfile (server.mappath (ชื่อไฟล์), 1, true)
fsofileread = objcountfile.readall
objcountfile.close
setObjcountFile = ไม่มีอะไร
setObjfso = ไม่มีอะไร
endfunction
使用 fso 读取文件某一行的函数
functionfsolinedit (ชื่อไฟล์, ผ้าลินิน)
iflinenum <1thenexitfunction
dimfso, f, temparray, tempcnt
setfso = server.createObject ("Scripting.FilesYstemObject")
ifnotfso.fileexists (server.mappath (ชื่อไฟล์)) thenexitfunction
setf = fso.opentextfile (server.mappath (ชื่อไฟล์), 1)
ifnotf.atendofstreamthen
tempcnt = f.readall
f.close
setf = ไม่มีอะไร
temparray = split (tempcnt, chr (13) & chr (10))
iflinenum> ubound (temparray)+1 จากนั้น
exitfunction
อื่น
fsolinedit = temparray (linenum-1)
endif
endif
endfunction
使用 fso 写文件某一行的函数
functionfsolineWrite (ชื่อไฟล์, ผ้าลินิน, linecontent)
iflinenum <1thenexitfunction
dimfso, f, temparray, tempcnt
setfso = server.createObject ("Scripting.FilesYstemObject")
ifnotfso.fileexists (server.mappath (ชื่อไฟล์)) thenexitfunction
setf = fso.opentextfile (server.mappath (ชื่อไฟล์), 1)
ifnotf.atendofstreamthen
tempcnt = f.readall
f.close
temparray = split (tempcnt, chr (13) & chr (10))
iflinenum> ubound (temparray)+1 จากนั้น
exitfunction
อื่น
temparray (linenum-1) = linecontent