首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  用FileObject建立标准网站维护

7i24.Com不停为您服务


<%@ 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:\Inetpub\wwwroot\"

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 "<B>MP3 File!</B><BR>"
Response.Write objFile.Path & "<P>"

'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 "<B>File is too large! (" & objFile.Size & " bytes)</B><BR>"
Response.Write objFile.Path & "<P>"

'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 "<B>MP3 File!</B><BR>"
Response.Write objFile.Path & "<P>"
  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 "<B>File is too large! (" & objFile.Size & " bytes)</B><BR>"
Response.Write objFile.Path & "<P>"
  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:\Inetpub\wwwroot\"
Dim objFolder
Set objFolder = objFSO.GetFolder(strCurrentFolder)


IterateThroughDirectory objFolder
%>



  2002年1月14日  阅读 2916 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 显示多级目录和文件的源程序
下一篇: 用ASP创建PDF文件
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利