ASP Script Hangs

A

Andi B

Hi folks,

Wondering if anyone can help me - I have recently set up a website on our
work intranet, which allows staff members in our team to attach a photo of
themselves to their profile on the page. The photos are uploaded to the
webserver by an ASP script. I am now trying to get an addition written
which allows for the deletion of old files that are no longer used by
anyones profile. I have written the following to list the contents of the
folder, but whenever I test the script on my home computer (WinXP Pro, SP2,
IIS 5.1) the ASP hangs - it produces no output, not even an error. Can
anyone offer any assistance on what I might need to do to get it working
correctly?

<%@ Language=VBScript %>

<%
Option Explicit
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Dim objFolder

Dim strCurrentFolder
strCurrentFolder = "images/staff"

Set objFolder = objFSO.GetFolder(strCurrentFolder)

Dim objFile

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

Set objFSO = Nothing
Set objFolder = Nothing
%>

Thanks in advance of any assistance,

Andi
 
R

Roland Hall

in message
: For Each objFile in strCurrentFolder.Files

for each objFile in objFolder.Files

--
Roland Hall
/* 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. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
A

Andi B

For this test, I have set the IUSR account permissions to Full Control, and
still nothing happens. I'm not sure how I can change the accounts permission
to access the FileSystemObject though.

Regards,

Andi
 
M

Mark Schupp

Are you sure it is hanging or could it just not be producing any output?
What does view source show?
 
R

Roland Hall

in message
: "Andi B" wrote in message
: :: 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. */
 
A

Andi B

Sir you are a genius. Just tested this code and it works brilliantly, thank
you very much!

I can't promise that I won't be back asking for more help, but in the mean
time, thank you.

Regards,

Andi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top