ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 用FileObject建立标准网站维护(转)

用FileObject建立标准网站维护(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-05-09 10:30:04 0 删除 编辑
<%@ Language=VBScript %>
<%
'Always do this: (good programming practice!)
Option Explicit
'Declare our FileSystemObject variable
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Dim objFolder


Dim strCurrentFolder
strCurrentFolder = "C:Inetpubwwwroot"

Set objFolder = objFSO.GetFolder(strCurrentFolder)

'Declare a file object
Dim objFile

'What is the maximum size of a file in bytes?
Const MaxSize = 5000 '50 KB


'Did we find any violating files?
Dim bolViolators
bolViolators = False

'Now, use a for each...next to loop through the Files collection
For Each objFile in objFolder.Files
  'Check to see if objFile is an MP3
  If LCase(Right(objFile.Name, 4)) = ".mp3" then
'Print out the violating file name and location
Response.Write "MP3 File!
"
Response.Write objFile.Path & "

"

'We found a violator
bolViolators = True
  End if

  'Make sure the file isn't too big
  If objFile.Size > MaxSize then
'Print out the violating file name and location
Response.Write "File is too large! (" & objFile.Size & " bytes)
"
Response.Write objFile.Path & "

"

'We found a violator
bolViolators = True
  End If
Next

'Now, if we didn't have any violating files, say so!
If Not bolViolators then
Response.Write "No violating Files..."
End if

'Clean up...
Set objFSO = Nothing
Set objFolder = Nothing
%>

<%@ Language=VBScript %>
<%Option Explicit %>
<%
Sub IterateThroughDirectory(objFolder)
'Process each file to determine if it is larger than 50kb
'or is of type MP3
'What is the maximum size of a file in bytes?
Const MaxSize = 50000 '50 KB

'Now, use a for each...next to loop through the Files collection
For Each objFile in objFolder.Files
  'Check to see if objFile is an MP3
  If LCase(Right(objFile.Name, 4)) = ".mp3" then
'Print out the violating file name and location
Response.Write "MP3 File!
"
Response.Write objFile.Path & "

"
  End if

  'Make sure the file isn't too big
  If objFile.Size > MaxSize then
'Print out the violating file name and location
Response.Write "File is too large! (" & objFile.Size & " bytes)
"
Response.Write objFile.Path & "

"
  End If
Next

Dim objFile
For Each objFile in objFolder.Files
if Lcase(Right(objFile.Name,4)) = ".mp3" then
objDict.Add CStr(iCount), objFile.Path
iCount = iCount + 1
end if
Next

Dim objSubFolder
For Each objSubFolder in objFolder.SubFolders
IterateThroughDirectory objSubFolder
Next
End Sub

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Dim strCurrentFolder
strCurrentFolder = "C:Inetpubwwwroot"
Dim objFolder
Set objFolder = objFSO.GetFolder(strCurrentFolder)


IterateThroughDirectory objFolder


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10294527/viewspace-124710/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    3481
  • 访问量
    3019264