FileSystemObject CreateTextFile falling over

I

Iain Bishop

I am trying to execute the following function which performs four tests to
make sure the current environment is capable of uploading files. Test 1
completes ok, but test 2 results in the page hanging indefinitely. An error
number is not returned (it just hangs on the line: Set testFile =
fso.CreateTextFile(fileName, true) ). However when I execute test 2 using
VBScript from within an Excel macro it creates the text file without any
problem.
I have given IUSR & IWAM Administrator rights but this has not helped.

Does anyone please have any ideas?

Many Thanks
Iain

function TestEnvironment()
Dim fso, fileName, testFile, streamTest
TestEnvironment = ""

'Test 1
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(uploadsDirVar) then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not
exist.</B><br>The value of your uploadsDirVar is incorrect. Open
AdminFileUpload.asp in an editor and change the value of uploadsDirVar to
the pathname of a directory with write permissions."
exit function
end if

'Test 2
fileName = uploadsDirVar & "\test.txt"
on error resume next
Set testFile = fso.CreateTextFile(fileName, true)
If Err.Number<>0 then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have
write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open
AdminFileUpload.asp in an editor and change the value of uploadsDirVar to
the pathname of a directory with write permissions."
exit function
end if
Err.Clear
testFile.Close

'Test 3
fso.DeleteFile(fileName)
If Err.Number<>0 then
TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have
delete permissions</B>, although it does have write permissions.<br>Change
the permissions for IUSR_<I>computername</I> on this folder."
exit function
end if
Err.Clear

'Test 4
Set streamTest = Server.CreateObject("ADODB.Stream")
If Err.Number<>0 then
TestEnvironment = "<B>The ADODB object <I>Stream</I> is not
available in your server.</B><br>Check the Requirements page for information
about upgrading your ADODB libraries."
exit function
end if
Set streamTest = Nothing
end function
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top