asp自動創(chuàng)建文件夾
來源:易賢網(wǎng) 閱讀:1297 次 日期:2014-08-26 09:55:35
溫馨提示:易賢網(wǎng)小編為您整理了“asp自動創(chuàng)建文件夾”,方便廣大網(wǎng)友查閱!

在asp操作文件中,遇到了創(chuàng)建多級文件夾,其實一級別的創(chuàng)建文件夾很簡單,就fso(路徑)即可,但是遇到了多級文件夾,這就得寫函數(shù)來創(chuàng)建多級文件夾

相關(guān):php自動創(chuàng)建文件夾

asp自動創(chuàng)建多級文件夾,當(dāng)其中文件夾不存在時,自動創(chuàng)建文件夾.

代碼如下:

<%@LANGUAGE = VBScript%>

<%Option Explicit%>

<%'asp版本自動創(chuàng)建文件夾

Dim fso,fso_flag,base,path,i

set fso = CreateObject("Scripting.FileSystemObject")

If isobject(fso) Then

fso_flag = True

Else

fso_flag = false

End If'

If not fso_flag Then response.write"不支持fso.",response.End()

base = request.ServerVariables("APPL_PHYSICAL_PATH")'獲取本地基本物理路徑

'asp自動創(chuàng)建文件夾函數(shù)開始

Function createdir(path)

Dim temp_path,temp_path_array '定義私有路徑

path = Replace(path,"\","/")

' response.write path

If isnull(path) or path = "" Then

createdir = False

Exit Function

End if

If not fso.FolderExists(path) then

'獲取次級目錄路徑

temp_path_array = Split(path,"/")

For i = 0 To UBound(temp_path_array)-1

temp_path = temp_path&temp_path_array(i)&"/"

Next'

temp_path = Left(temp_path,Len(temp_path)-1)'獲取次級目錄

if createdir(temp_path) Then

fso.CreateFolder (path)

createdir = true

End If

else'www.forasp.cn

createdir = true

Exit Function

End if

End Function

'asp創(chuàng)建多級文件夾函數(shù)完畢

path = base&"a/b/c"'因為path獲取站點物理路徑最后包括"/",所以建立文件要以空開頭,然后是文件夾名

'response.write path

If (createdir(path)) Then

response.write "已經(jīng)創(chuàng)建"

Else

response.write "創(chuàng)建失敗"

End if

%>

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
下一篇:HEX解碼
易賢網(wǎng)手機網(wǎng)站地址:asp自動創(chuàng)建文件夾
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報警專用圖標(biāo)