ASP自动创建目录与文件是工作中经常需要用到的一个功能,尤其是在上传文件、生成HTML静态页的时候,我们都需要判断目录是否存在,如不存在自动创建等。
ASP实现FSO创建文件的函数
'================================================================
'code 内容
'path 目录
'textfile 文件
'技术支持:www.qdxw.net
'================================================================
function fso_create_textfile(code,path,textfile)
call fso_create_folder(path) '检测生成目录是否存在,如不存在则建立.
dim fsoctf_code_code,fsoctf_code_path,fsoctf_textfile,fsoctf,fsoctf_ctf
fsoctf_code = code
fsoctf_path = Server.MapPath(path)
fsoctf_textfile = textfile
Set fsoctf = Server.CreateObject("Scripting.FileSystemObject")
Set fsoctf_ctf = fsoctf.CreateTextFile(fsoctf_path&"/"&fsoctf_textfile,true)
fsoctf_ctf.WriteLine fsoctf_code
fsoctf_ctf.close
set fsoctf_ctf=nothing
set fsoctf=nothing
End function
ASP实现FSO创建目录的函数
'================================================================
'FSO生成目录
'folder 路径
'相对路径格式: acc
'绝对路径格式: ../../c|
'技术支持:www.qdxw.net
'================================================================
function fso_create_folder(folder)
'首选判断要建立的文件夹是否已经存在
dim fsocf_folder,fsocf,fsocf_cf
fsocf_folder = Server.Mappath(folder)
Set fsocf = Server.CreateObject("Scripting.FileSystemObject")
'检查文件夹是否存在
If fsocf.FolderExists(fsocf_folder)= true Then
'存在
Else
'不存在,则建立
Set fsocf_cf = fsocf.CreateFolder(fsocf_folder)
fsocf_cf.close
Set fsocf_cf = nothing
End If
Set fsocf = nothing
End function
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。