<%
' 網站根目錄
const global_default_root_path = "/"
' 描述: 建立目錄的程序,如果有多級目錄,則一級一級的創建
' 作者: xiaoyuehen
' 日期: 2006-6-3
' 參數: strlocalpath : string, 創建路徑, 必須為物理路徑
' 返回: True/False
function create_directory(strlocalpath)
create_directory = false
dim strlocalfolder
dim strpath, tmppath, tmptpath
dim arrpathlist, intlevel
strlocalfolder = server.mappath(global_default_root_path)
if left(strlocalpath, len(strlocalfolder)) <> strlocalfolder then
exit function
end if
' 獲得目錄
strpath
= replace(strlocalpath, strlocalfolder, "")
if left(strpath, 1) = "/" then
strpath = right(strpath, len(strpath) - 1)
end if
dim objfolder
set objfolder = server.createobject("Scr if objfolder.folderexists(strlocalpath) then end if arrpathlist intlevel = ubound(arrpathlist) dim i tmptpath = "" for i = 0 to intlevel tmppath = strlocalfolder & "/" & tmptpath next set objfolder = nothing create_directory = true fcreate_file = false dim strpath strpath = left(strfilename, instrrev(strfilename, "/", -1, 1)) '檢測路徑及文件名有效性 if not(create_directory(strpath)) then exit function const forreading = 1, forwriting = 2, forappending = 8 dim fso, f set fso = createobject("scripting.filesystemobject") set f = fso.opentextfile(strfilename, forwriting, true, -2) f.write strcontent f.close set fso = nothing set f = nothing fcreate_file = true screate_file = false dim strpath strpath = left(strfilename, instrrev(strfilename, "/", -1, 1)) '檢測路徑及文件名有效性 if not(create_directory(strpath)) then exit function dim ado_stream const forreading = 1, forwriting = 2 set ado_stream = server.createobject("adodb.stream") with ado_stream end with set ado_stream = nothing screate_file = true
create_directory = true
exit function
= split(strpath, "/")
tmptpath = tmptpath & arrpathlist(i) & "/"
if not objfolder.folderexists(tmppath) then objfolder.createfolder tmppath
end function
' 描述: fso 生成文件
' 作者: xiaoyuehen
' 日期: 2006-6-3
' 參數: strlocalpath : string, 創建路徑, 必須為物理路徑
' 返回: True/False
function fcreate_file(strfilename, byref strcontent)
end function
' 描述: stream 生成文件
' 作者: xiaoyuehen
' 日期: 2006-6-3
' 參數: strfilename : string, 文件完整路徑, 必須為物理路徑
'
strcontent : string, 文本內容
' 返回: True/False
function screate_file(strfilename, byref strcontent)
.Open
.type = 2
.Writetext(strcontent)
.SaveToFile strfilename, forwriting
.SetEOS
end function%>
新聞熱點
疑難解答