28,409
社区成员




<%
On Error Resume Next
Set txtFile=FSO.OpenTextFile(Server.MapPath(FileName),2,True)
If Err.Number=70 Then
isErr_=-1
ErrMessage_="没有权限,文件只读或被锁定。"
Else
txtFile.Write value
End If
Set txtFile=NoThing
'不过 fso 只对 ansi 和 unicode 支持的比较好,如果其他编码格式,最好使用 ado.stream
Sub SaveToFile(FileName,Code,Charset,Path)
On Error Resume Next
Dim File,sPath,FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
sPath = Path
If sPath = "" Then sPath = "."
If Right(sPath,1) = "/" Or Right(sPath,1) = "\" Then sPath = Left(sPath,Len(sPath) - 1)
If Not FSO.FolderExists(Server.MapPath(sPath)) Then
FSO.CreateFolder(Server.MapPath(Path))
End If
Set FSO = Nothing
If Err Then
response.write sPath
Response.Write "File save failed,please check the path."
response.write Err.description
Exit Sub
End If
Set File = Server.CreateObject("Adodb.Stream")
File.Charset = Charset
File.Mode = 3
File.Open
File.Type = 2
File.Position = 0
File.WriteText Code
File.SaveToFile Server.MapPath(sPath & "/" & FileName), 2
File.Close
Set File = Nothing
End Sub
%>