【问题标题】:Performance tuning in iterating through FileSystemObject Collections遍历 FileSystemObject 集合时的性能调整
【发布时间】:2012-05-02 16:12:11
【问题描述】:

我不知道系统在For Each objFile in objFolder.Files 这一行的内存中存储了多少,以及使用类似objFile.Files.Count 的东西进行迭代是否会更有益。有谁知道使用以下代码是否会产生任何重大的性能问题?

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

'Get the folder object associated with the directory
Dim objFolder
Set objFolder = objFSO.GetFolder("C:\InetPub\wwwroot")

Response.Write "The files found in " & objFolder.Name & ":<br>"

'Loop through the Files collection
Dim objFile
For Each objFile in objFolder.Files
  Response.Write objFile.Name & "<br>"
Next

'Clean up!
Set objFolder = Nothing
Set objFile = Nothing
Set objFSO = Nothing

【问题讨论】:

    标签: performance filesystemobject fso


    【解决方案1】:

    对于objFolder.Files中的每个objFile这一行不知道系统在内存中存储了多少

    不确定您的意思,但这只会遍历文件 objects 的集合,不会使用大量内存。如果这是您的问题,此调用显然不会加载内存中文件的内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-28
      • 2018-11-17
      • 2014-04-11
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 2020-06-23
      相关资源
      最近更新 更多