ASP生成日志文件
<%
' witefile.asp
' 写入文件
' strFile 文件名(路径) , strContent 写入的内容, blnAppend 是否追加
Function WriteFile(strFile, strContent, blnAppend)
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If blnAppend Then
Set objWriteText = objFSO.OpenTextFile(strFile,8,True)
Else
Set objWriteText = objFSO.OpenTextFile(strFile,2,True)
End If
objWriteText.WriteLine (strContent)
Set objWriteText = Nothing
Set objFSO = Nothing
' 容错处理
Select Case Err
Case 424 Response.Write "路径未找到或者该目录没有写入权限."
Case Else Response.Write Err.Description
'Case Else Response.Write ErrMsg
End Select
End Function
'调用方法
'WriteFile "c:\dd.ini", "dd", True
'Call WriteFile ("c:\dd.ini", "dd", True)
'可以创建文件,但是不能创建目录
%>
' witefile.asp
' 写入文件
' strFile 文件名(路径) , strContent 写入的内容, blnAppend 是否追加
Function WriteFile(strFile, strContent, blnAppend)
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If blnAppend Then
Set objWriteText = objFSO.OpenTextFile(strFile,8,True)
Else
Set objWriteText = objFSO.OpenTextFile(strFile,2,True)
End If
objWriteText.WriteLine (strContent)
Set objWriteText = Nothing
Set objFSO = Nothing
' 容错处理
Select Case Err
Case 424 Response.Write "路径未找到或者该目录没有写入权限."
Case Else Response.Write Err.Description
'Case Else Response.Write ErrMsg
End Select
End Function
'调用方法
'WriteFile "c:\dd.ini", "dd", True
'Call WriteFile ("c:\dd.ini", "dd", True)
'可以创建文件,但是不能创建目录
%>