【www.gdgbn.com--php常用代码】

 "==============================
 "函 数 名: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

本文来源:http://www.gdgbn.com/jiaocheng/20748/