Results 1 to 3 of 3

Thread: Classic ASP Do until FileExists?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    482

    Classic ASP Do until FileExists?

    I am using a WScript.Shell to call a Java class that creates a file. I need to be able to wait until the file gets created (usually about 15-20 seconds) before I try to open this file in the ASP page.

    I tried to use a Do Until fs.FileExists(outFile) loop but that pegs the CPU Cycles out and then the file never gets created. The same goes for any of the normal "Do until" pause couters floating around on the net.

    I have also read about WScript.Sleep but that apparently does not work in ASP, only in VBScript files.

    I CANNOT use a page refresh to try and check for the file either. The reason is there is a lot of things happening on this page before this point (creating a temp folder, copying files, etc.) and there is response.write after each step to keep the user informed. A refresh would start the process all over.

    What I really need is a way to loop asynchronously to allow the background Java to finish creating the file instead of the loop pegging out the server. So something like:
    Code:
    Do until fs.FileExists(outFile)
        DoEvents
    loop
    Anyone have any ideas?

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Classic ASP Do until FileExists?

    I'm doing something similar in VB.Net web services with ASP.Net - not fully complete yet but this thread (and a few related one) discuss methods

    http://www.vbforums.com/showthread.php?t=671789

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    482

    Re: Classic ASP Do until FileExists?

    I found a cheater way to get it done, by spawning additional short term "do nothing" type shell processes in the Loop. Really I am just calling Shell("java", , wait), which causes java.exe to return usage information and then exit for each pass of the loop. This allows the file to actually get created without timing out but is not really a good thing to do.

    I am now considering packaging this portion of the code into an API and calling it that way, to try and make this more efficient and actually use a real DoEvents.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width