小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

fso應(yīng)用中的幾個(gè)小函數(shù)-asp教程-asp學(xué)習(xí)網(wǎng)

 張青 2009-02-28

<%
'功能:判斷文件名是否合法
'isFileName [filename]
'文件名不能包含下列任何字符之一
' \ / : * ? " < > |
Function isFileName(sFileName)
Dim sErrorStr, i
isFileName = TRUE
sErrorStr = Array("\", "/", ":", "*", "?", """", "<", ">", "|")
If Len(sFileName & "") = 0 Then isFileName = FALSE : Exit Function
For i = 0 To 8
If InStr(sFileName, sErrorStr(i)) > 0 Then
isFileName = FALSE
End If
Next
End Function
%>

 <%
'功能:刪除一個(gè)目錄。除目錄本身外,還將刪除指定目錄下的所有子目錄和文件。用于刪除目錄樹(shù)。
'RD [Drive:]Path
'支持刪除多級(jí)目錄,支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。
''需要PATH函數(shù)在下面
Function RD(ByVal sPath)
On Error Resume Next
Dim oFSO
sPath = Path(sPath) '//此處需要PATH函數(shù)
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists(sPath) Then
oFSO.DeleteFolder sPath, True
RD = True
End If
Set oFSO = Nothing
If Err.Number > 0 Then
Err.Clear()
RD = False
Else
RD = True
End If
End Function
%>

 <%
'功能:創(chuàng)建目錄。
'MD [Drive:]Path
'支持創(chuàng)建多級(jí)目錄,支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。

'需要PATH函數(shù)在下面

Function MD(sPath)
On Error Resume Next
Dim aPath, iPath, i, sTmpPath
Dim oFSO
sPath = Path(sPath) '//此處需要PATH函數(shù)
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
If oFSO.FolderExists(sPath) Then MD = True : Exit Function
aPath = Split(sPath, "\")
iPath = UBound(aPath)
sTmpPath = ""
For i = 0 To iPath
sTmpPath = sTmpPath & aPath(i) & "\"
If Not oFSO.FolderExists(sTmpPath) Then
oFSO.CreateFolder(sTmpPath)
End If
Next
Set oFSO = Nothing
If Err.Number > 0 Then
Err.Clear()
MD = False
Else
MD = True
End If
End Function
%>

 <%
'功能:計(jì)算目錄絕對(duì)路徑。
'PATH [Drive:]Path
'支持多級(jí)目錄,支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。


Function Path(ByVal sPath)
On Error Resume Next
If Len(sPath&"") = 0 Then sPath = "./"
If Right(sPath, 1) = ":" Then sPath = sPath & "\"
sPath = Replace(sPath, "/", "\")
sPath = ReplaceAll(sPath, "\\", "\", False)
sPath = ReplaceAll(sPath, "...", "..\..", False)
If (InStr(sPath, ":") > 0) Then
sPath = sPath
Else
sPath = Server.Mappath(sPath)
End If
Path = sPath
End Function
%>

<%
'功能:判斷文件是否已存在。
'IsFileExist(文件名)


Public Function IsFileExist(ByVal sFileName)
On Error Resume Next
Dim oFSO
sFileName = PATH(sFileName)
Set oFSO = CreateObject("Scripting.FileSystemObject")
IsFileExist = oFSO.FileExists(sFileName)
Set oFSO = Nothing
End Function
%>
<%
'功能:判斷文件夾是否已存在。
'IsFolderExist(文件名)

Public Function IsFolderExist(ByVal sFolderName)
On Error Resume Next
Dim oFSO
sFolderName = PATH(sFolderName)
Set oFSO = CreateObject("Scripting.FileSystemObject")
IsFolderExist = oFSO.FolderExists(sFolderName)
Set oFSO = Nothing
End Function
%>

<%
'功能:創(chuàng)建十進(jìn)制文本文件。
'CreateTextFile(文件內(nèi)容,文件名)
'文件名支持相對(duì)路徑和絕對(duì)路徑。
'支持用“...”指定父目錄的父目錄。

Function CreateTextFile (ByVal sText, ByVal sFileName)
On Error Resume Next
sFileName = Path(sFileName)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWrite = oFSO.OpenTextFile(sFileName, 2, True)
oWrite.Write sText
oWrite.Close
Set oFSO = Nothing
Set oWrite = Nothing
If Err.Number > 0 Then
Err.Clear()
CreateTextFile = False
Else
CreateTextFile = True
End If
End Function
%>
 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多