DownloadTime 属性

       

返回 Long 类型的值,代表给定文件下载所需的模拟时间(以秒为单位)。只读。

expression.DownloadTime

expression  必选。返回 WebFile 对象的表达式。

说明

此属性与 ConnectionSpeed 属性联合使用可以确定显示在“慢速网页”报表中的文件。

示例

下列示例显示当前站点中下载时间超过指定值的所有文件的名称。该子例程提示用户以秒为单位输入下载时间。然后,再搜索 All 集合中的每个文件,并显示下载时间超过指定秒数的任何文件名。Name 属性值会添加到一个 String 类型的值中,其中包含集合中所有匹配的文件名。然后,向用户显示这个存储在变量 strName 中的 String 值。如果站点中找不到匹配的文件,则向用户显示一条消息。

Sub DownloadTime()
'Displays the names of all files with a download time greater than
'a given value

    Dim objApp As FrontPage.Application
    Dim objwebFile As WebFile
    Dim objWebFiels As WebFiles
    Dim strSec As String    'User input value
    Dim strNames As String  'Name of all matching files
    Dim blnFound As Boolean 'Boolean flag

    Set objApp = FrontPage.Application
    Set objWebFiles = objApp.ActiveWeb.AllFiles
    blnFound = False
    'Prompt user to enter input
    strSec = InputBox("Enter the number of seconds download time.")
    'Search through each file in the collection
    For Each objwebFile In objWebFiles
        'If user input is less than download time
        If strSec < objwebFile.DownloadTime Then
            blnFound = True
            If strName = "" Then
                strName = strName & objwebFile.Name
            Else
                'Otherwise add next file name to string
                strName = strName & ", " & vbCr & objwebFile.Name
            End If
        End If
    Next objwebFile

    If blnFound = True Then
       'Display names of all files that match the criteria
       MsgBox "The files that take longer than " & _
              strSec & " seconds to download are: " & vbCr & vbCr & _
              strName & "."
    Else
        'No files, display message
        MsgBox "There are no files that match your criteria."
    End If

End Sub