日期:2010-02-06  浏览次数:20920 次

 '=============================================================
 '过程名:CreatedTextFile
 '作  用:创建文本文件
 '参  数:filename  ----文件名
 '        body  ----主要内容
 '=============================================================
 Public Function CreatedTextFile(ByVal FileName,ByVal body)
  On Error Resume Next
  Dim f,sName
  FileName = Replace(Replace(FileName, "/", "\"), "\\", "\")
  If InStr(FileName, ":") = 0 Then FileName = Server.MapPath(FileName)
  sName=Mid(FileName,InStrRev(FileName,"\")+1,Len(FileName))
  If InStr(sName,".")=0 Then FileName = FileName &"\index.html"
  If MainSetting(7)="0" Then
   Set f = fso.CreateTextFile(FileName,True, False)
   f.Write body
   f.Close
   Set f = Nothing
  Else
   If MainSetting(7)="2" Then
    NewAspStream.charset="UTF-8"
   ElseIf MainSetting(7)="3" Then
    NewAspStream.charset="BIG5"
   Else
    NewAspStream.charset="GB2312"
   End If
   NewAspStream.Type = 2'设置内容为文本
   NewAspStream.Mode = 3'设置为可读可写
   NewAspStream.open()
   NewAspStream.WriteText(body)
   NewAspStream.SaveToFile FileName,2
   NewAspStream.Flush
   NewAspStream.close()
  End If
  If Err.Number <> 0 Then Err.Clear
 End Function