国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ASP自動檢測創建多級目錄,fso與stream生成文件函數

2019-11-17 04:12:21
字體:
來源:轉載
供稿:網友

<%

' 網站根目錄
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


create_directory = true


exit function

end if

arrpathlist
= split(strpath, "/")

intlevel

= ubound(arrpathlist)

 

dim i

tmptpath = ""

for i = 0 to intlevel


tmptpath = tmptpath & arrpathlist(i) & "/"

 

 

tmppath = strlocalfolder & "/" & tmptpath


if not objfolder.folderexists(tmppath) then objfolder.createfolder tmppath

next

 

set objfolder = nothing

create_directory = true
end function
' 描述:
fso 生成文件
' 作者: xiaoyuehen
' 日期: 2006-6-3
' 參數: strlocalpath : string, 創建路徑, 必須為物理路徑
' 返回: True/False
function fcreate_file(strfilename, byref strcontent)

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
end function
' 描述: stream 生成文件
' 作者: xiaoyuehen
' 日期: 2006-6-3
' 參數: strfilename : string, 文件完整路徑, 必須為物理路徑
'
   strcontent : string, 文本內容
' 返回: True/False
function screate_file(strfilename, byref strcontent)

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


.Open


.type = 2


.Writetext(strcontent)


.SaveToFile strfilename, forwriting


.SetEOS

end with

set ado_stream = nothing

screate_file = true
end function%>


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 乌拉特中旗| 林州市| 马龙县| 民乐县| 灌云县| 山东省| 海南省| 隆昌县| 乾安县| 科尔| 陆川县| 晋城| 许昌县| 青川县| 昆明市| 东乌| 沭阳县| 土默特右旗| 黔江区| 广河县| 武邑县| 隆子县| 枝江市| 肇源县| 玉门市| 荔浦县| 高唐县| 蕉岭县| 赣榆县| 云龙县| 吉木乃县| 徐州市| 岳西县| 神农架林区| 皮山县| 吉首市| 民和| 金华市| 福鼎市| 玉树县| 洪泽县|