FileSystemObject CreateTextFile falling over

Discussion in 'ASP General' started by Iain Bishop, Sep 4, 2006.

  1. Iain Bishop

    Iain Bishop Guest

    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
     
    Iain Bishop, Sep 4, 2006
    #1
    1. Advertising

  2. Iain Bishop

    Mike Brind Guest

    Mike Brind, Sep 4, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spradl

    FileSystemObject.CreateTextFile Problem

    spradl, Aug 12, 2003, in forum: ASP General
    Replies:
    9
    Views:
    185
    Ray at
    Aug 14, 2003
  2. eddie wang

    filesys.createTextFile limit

    eddie wang, Dec 11, 2003, in forum: ASP General
    Replies:
    3
    Views:
    173
    Aaron Bertrand - MVP
    Dec 11, 2003
  3. Anchorman

    CreateTextFile hangs

    Anchorman, Jan 7, 2004, in forum: ASP General
    Replies:
    1
    Views:
    124
    Ray at
    Jan 7, 2004
  4. Séverine Donnay

    CreateTextFile deny on IIS

    Séverine Donnay, Jan 8, 2005, in forum: ASP General
    Replies:
    14
    Views:
    238
    Séverine Donnay
    Jan 9, 2005
  5. NeilS
    Replies:
    2
    Views:
    189
    NeilS
    Apr 28, 2005
Loading...

Share This Page