Re: ASP Script Hangs

From: Roland Hall (nobody_at_nowhere)
Date: 03/23/05


Date: Wed, 23 Mar 2005 15:54:40 -0600


"Roland Hall" wrote in message
news:%23MC1p29LFHA.1948@TK2MSFTNGP14.phx.gbl...
: "Andi B" wrote in message
: news:4241bf6b$0$26751$cc9e4d1f@news.dial.pipex.com...
:: For Each objFile in strCurrentFolder.Files
:
: for each objFile in objFolder.Files

Actually you have more than one error. FSO expects a physical path, not
virtual. You need Server.MapPath and my first suggestion.
I just tried this and it works. Just change the name of your folders. I'm
using "/images"

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True

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

Dim objFolder

Dim strCurrentFolder
strCurrentFolder = Server.MapPath("/images")

Set objFolder = objFSO.GetFolder(strCurrentFolder)

Dim objFile

For Each objFile in objFolder.Files
  Response.Write objFile.Name & " (" & objFile.Size & "bytes)<br>"
Next

Set objFSO = Nothing
Set objFolder = Nothing
%>

http://kiddanger.com/lab/files3.asp

-- 
Roland Hall
- some days are easier than others -
/* This information is distributed in the hope that it will be useful, but 
without any warranty; without even the implied warranty of merchantability 
or fitness for a particular purpose. */


Relevant Pages

  • Re: email notification of new file arrival
    ... Dim objFSO ... Set objFSO = CreateObject ... For Each objFile In objDir.Files ...
    (microsoft.public.office.developer.automation)
  • Re: Open files from folder by matching name
    ... Dim intLastRow As Integer ... Dim objFile As Object ... Dim strSearchFor As String ... Set objFSO = CreateObject ...
    (microsoft.public.excel.programming)
  • Delete blank files via DTS
    ... Dim objFolder ... Set objFSO = CreateObject ... For Each objFile In objFolder.Files ...
    (microsoft.public.sqlserver.dts)
  • Re: Making links with the FileSystemObject...
    ... Set objFSO = Server.CreateObject ... Dim objFolder ... For Each objFile in objFolder.Files ...
    (microsoft.public.scripting.vbscript)
  • Re: Excel DIR
    ... > Dim objFSO As Scripting.FileSystemObject ... > Dim objFile As Scripting.File ... > Set objFSO = New Scripting.FileSystemObject ... > Set objFolder = objFSO.GetFolder ...
    (microsoft.public.excel.programming)