文件操作

来源:互联网 发布:梦幻琵琶知多少钱 编辑:程序博客网 时间:2024/04/20 00:22

做了一个新闻发布,写了些文件操作函数,把他们记录在此

 

 

<%
'生成一个新文件并写入内容

Function CreateNewFile(ByVal FileName)

Set afile = fso.Createtextfile(FileName,true)
afile.writeline filecontent
afile.close
set afile = nothing

End Function

'读取模板文件内容
Function GetLyrics()

Dim TextStream
Dim S
Dim File

Set TextStream = FSO.OpenTextFile(FolderPath&tempfilename,1)

S = TextStream.ReadAll & NewLine & NewLine
TextStream.Close

GetLyrics = S

End Function

'读取某一页的内容
Function ReadFileContent(filename)

Dim TextStream
Dim S
Dim File

Set TextStream = FSO.OpenTextFile(FolderPath&filename,1)

S = TextStream.ReadAll & NewLine & NewLine
TextStream.Close

ReadFileContent = S

End Function

'检测文件是否存在
'假设已经建立fso
Function CheckFileExists(FilePath)
if fso.FileExists(FilePath) then
CheckFileExists = true
else
CheckFileExists = false
end if
End Function

'删除某文件
'假设已经建立fso
Function DeleteFile(FilePath)
if CheckFileExists(FilePath) then
Set f = fso.GetFile(FilePath)
f.Delete
set f = nothing
DeleteFile = true '文件被成功删除
else
DeleteFile = false '文件不存在
End if
End Function


'删除某一产品所有详细页
Function DeleteOneProMsg(ByVal PageUrl)
dim tempar
tempar = split(PageUrl,"|")

for i = 1 to ubound(tempar)
DeleteFile( ( FolderPath&tempar(i) ) ) '删除所有信息页
next

End Function

'更新一个产品的内容
'其实为覆盖写入
Function UpdateFile(filepath)

Dim f
Set f = fso.OpenTextFile(filepath, 2, True)
f.Write newcontent
f.close
set f = nothing
End Function


%>

原创粉丝点击