'==============================
'函 數 名:FsoLineWrite
'作 用:按行寫入檔案
'參 數:檔案相對路徑FilePath,寫入行號LineNum,寫入內容LineContent
'==============================
Function FsoLineWrite(FilePath,LineNum,LineContent)
If LineNum<1 Then Exit Function
Set Fso=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
If Not Fso.FileExists(Server.MapPath(FilePath)) Then Exit Function
Temp=FsoFileRead(FilePath)
TempArr=Split(Temp,Chr(13)&Chr(10))
TempArr(LineNum-1)=LineContent
Temp=Join(TempArr,Chr(13)&Chr(10))
Call CreateFile(FilePath,Temp)
Set Fso=Nothing
End Function
'==============================
'函 數 名:FsoFileRead
'作 用:讀取檔案
'參 數:檔案相對路徑FilePath
'==============================
Function FsoFileRead(FilePath)
Set objAdoStream = Server.CreateObject("A"&"dod"&"b.St"&"r"&"eam")
If Err.Number=-2147221005 Then
Response.Write "方卡錯誤提示:伺服器不支援ADODB.Stream"
Err.Clear
Response.End
End If
With objAdoStream
.type=2
.mode=3
.Charset = "utf-8"
.Open
.LoadFromFile Server.MapPath(FilePath)
.Position = 2
FsoFileRead=.ReadText
End With
objAdoStream.Close
Set objAdoStream=Nothing
End Function