FSO(fileSystemObject)判断文件及文件夹是否存在
作者:admin 日期:2007-10-06
fso中判断文件夹是否存在
set fso = server.createobject("scripting.filesystemobject")
if fso.FolderExists(server.mappath("../folderName"))=false then
REsponse.write("此文件夹不存在")
end if
fso中判断文件是否存在
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath("../folderName/fileName.htm")) = true then
Response.write("文件存在")
end if
fso中写文件
dim fileName,fileContent
fileName = replace(date(),"-","")
randomize
fileName = fileName & cstr(int(rnd(10)*100000)) & ".htm"
HtmlName = fileName 'HtmlName为数据库中的文件名
set fso = server.CreateObject("scripting.filesystemobject")
if fso.FolderExists(server.MapPath("./Files"))=false then '检查要生成的HTML文件夹是否存在
fso.CreateFolder(server.MapPath("../Files"))
end if
fileName = server.MapPath("../Files") & "/" & fileName
set MyFile = fso.opentextfile(fileName,2,true)
fileContent = "....(content)"
MyFile.write(fileContent)
MyFile.Close()
set MyFile = nothing
fso中删除文件
set fso = server.createobject("script.filesystemobject")
fileName = ..
fso.deletefile(fileName)
set fso = nothing
广告位