|
<%
'功能:判斷文件名是否合法 '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 %> <% <% Function MD(sPath) <% <%
'功能:判斷文件是否已存在。 '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 %> |
|
|
來(lái)自: 張青 > 《我的圖書(shū)館》