最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp读取写文件fso实例代码
时间:2009-07-11 编辑:简简单单 来源:一聚教程网
'==============================
'函 数 名: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
-
上一个: asp 字符转换成hex十六进制
-
下一个: asp 创建文件与文件夹
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14