2012-05-02 49 views
0

我不知道系統在此行的內存中存儲了多少For Each objFile in objFolder.Files以及使用諸如objFile.Files.Count之類的迭代是否更有利。有誰知道如果使用下面的代碼會造成任何重大的性能問題?通過FileSystemObject集合進行迭代時的性能調整

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 

回答

0

我不知道有多少系統存儲在內存中該行對於每個OBJFILE在objFolder.Files

不知道你的意思,但這種過度的集合將只循環的文件對象這將不會使用大量的內存。這個調用顯然不會加載內存中的文件的內容,如果這是你的問題。