最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > asp教程

ASP自动检测创建多级目录

日期:06-22    来源:网页设计秀    作者:cnwebshow整理

<%uGh中国设计秀

' 网站根目录uGh中国设计秀
const global_default_root_path = "/"uGh中国设计秀
' 描述: 建立目录的程序,如果有多级目录,则一级一级的创建uGh中国设计秀
' 作者: xiaoyuehenuGh中国设计秀
' 日期: 2006-6-3uGh中国设计秀
' 参数: strlocalpath : string, 创建路径, 必须为物理路径uGh中国设计秀
' 返回: True/FalseuGh中国设计秀
function create_directory(strlocalpath)uGh中国设计秀

create_directory = falseuGh中国设计秀

dim strlocalfolderuGh中国设计秀

dim strpath, tmppath, tmptpathuGh中国设计秀

dim arrpathlist, intleveluGh中国设计秀

strlocalfolder = server.mappath(global_default_root_path)uGh中国设计秀

if left(strlocalpath, len(strlocalfolder)) <> strlocalfolder thenuGh中国设计秀

uGh中国设计秀
exit functionuGh中国设计秀

end ifuGh中国设计秀

 uGh中国设计秀

' 获得目录uGh中国设计秀

strpathuGh中国设计秀

= replace(strlocalpath, strlocalfolder, "")uGh中国设计秀

if left(strpath, 1) = "" thenuGh中国设计秀

uGh中国设计秀
strpath = right(strpath, len(strpath) - 1)uGh中国设计秀

end ifuGh中国设计秀

 uGh中国设计秀

dim objfolderuGh中国设计秀

set objfolder   = server.createobject("Scripting.FileSystemObject")uGh中国设计秀

' 如果该目录已存在, 则返回 trueuGh中国设计秀

 uGh中国设计秀

   if objfolder.folderexists(strlocalpath) thenuGh中国设计秀

uGh中国设计秀
create_directory = trueuGh中国设计秀

uGh中国设计秀
exit functionuGh中国设计秀

end ifuGh中国设计秀

arrpathlistuGh中国设计秀
= split(strpath, "")uGh中国设计秀

intleveluGh中国设计秀

= ubound(arrpathlist)uGh中国设计秀

 uGh中国设计秀

dim iuGh中国设计秀

tmptpath = ""uGh中国设计秀

for i = 0 to intleveluGh中国设计秀

uGh中国设计秀
tmptpath = tmptpath & arrpathlist(i) & ""uGh中国设计秀

 uGh中国设计秀

 uGh中国设计秀

tmppath = strlocalfolder & "" & tmptpathuGh中国设计秀

uGh中国设计秀
if not objfolder.folderexists(tmppath) then objfolder.createfolder tmppathuGh中国设计秀

nextuGh中国设计秀

 uGh中国设计秀

set objfolder = nothinguGh中国设计秀

create_directory = trueuGh中国设计秀
end functionuGh中国设计秀
' 描述: fso 生成文件uGh中国设计秀
' 作者: xiaoyuehenuGh中国设计秀
' 日期: 2006-6-3uGh中国设计秀
' 参数: strlocalpath : string, 创建路径, 必须为物理路径uGh中国设计秀
' 返回: True/FalseuGh中国设计秀
function fcreate_file(strfilename, byref strcontent)uGh中国设计秀

fcreate_file = falseuGh中国设计秀

dim strpathuGh中国设计秀

strpath = left(strfilename, instrrev(strfilename, "", -1, 1))uGh中国设计秀

'检测路径及文件名有效性uGh中国设计秀

if not(create_directory(strpath)) then exit functionuGh中国设计秀

const forreading = 1, forwriting = 2, forappending = 8uGh中国设计秀

dim fso, fuGh中国设计秀

set fso = createobject("scripting.filesystemobject")uGh中国设计秀

set f = fso.opentextfile(strfilename, forwriting, true, -2)uGh中国设计秀

f.write strcontentuGh中国设计秀

f.closeuGh中国设计秀

set fso = nothinguGh中国设计秀

set f = nothinguGh中国设计秀

fcreate_file = trueuGh中国设计秀
end functionuGh中国设计秀
' 描述: stream 生成文件uGh中国设计秀
' 作者: xiaoyuehenuGh中国设计秀
' 日期: 2006-6-3uGh中国设计秀
' 参数: strfilename : string, 文件完整路径, 必须为物理路径uGh中国设计秀
'uGh中国设计秀
   strcontent : string, 文本内容uGh中国设计秀
' 返回: True/FalseuGh中国设计秀
function screate_file(strfilename, byref strcontent)uGh中国设计秀

screate_file = falseuGh中国设计秀

dim strpathuGh中国设计秀

strpath = left(strfilename, instrrev(strfilename, "", -1, 1))uGh中国设计秀

'检测路径及文件名有效性uGh中国设计秀

if not(create_directory(strpath)) then exit functionuGh中国设计秀

dim ado_streamuGh中国设计秀

const forreading = 1, forwriting = 2uGh中国设计秀

set ado_stream = server.createobject("adodb.stream")uGh中国设计秀

with ado_streamuGh中国设计秀

uGh中国设计秀
.OpenuGh中国设计秀

uGh中国设计秀
.type = 2uGh中国设计秀

uGh中国设计秀
.Writetext(strcontent)uGh中国设计秀

uGh中国设计秀
.SaveToFile strfilename, forwritinguGh中国设计秀

uGh中国设计秀
.SetEOSuGh中国设计秀

end withuGh中国设计秀

set ado_stream = nothinguGh中国设计秀

screate_file = trueuGh中国设计秀
end function%>uGh中国设计秀

本文引用地址:/bc/article_46233.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明