p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_howto thread: help/syntax guidance using attributes/methods of FSO


Message #1 by "Jeff Gaudet" <gaudet54@h...> on Wed, 7 Feb 2001 02:15:58 -0000
well, supposing that your relative path is correct, use the FileExists method of the
FSO:

(you probably want to rename your variables, hard to read and understand at a
glance)

dim objfile

getfile1......
...

If getfile2.FileExists(getfile1) then
  'the file exists, now check it's size
  set objfile = getfile2.getfile(getfile1)
  if objfile.size > 0 then
      'the file is larger than 0MB
  else
    'put your loop here to wait for the file to finish
    'unfortunately, i've never done a "timed" loop, but i guess,
    'you could try this - all though it will bring down the server's resources
    'briefly
    Do
       set objfile = nothing
       set objfile = getfile2.getfile(getfile1)
       if objfile.size > 0 then
           exit do
       end if
    loop until 1=2
else
    'the file doesn't exist
end if

the FSO stuff should work just fine, but i'd try to find a better way to "wait" for
the file to be created.

just some thoughts,

john


--- Jeff Gaudet <gaudet54@h...> wrote:
> My dillemma is that I am using the FileSystemObject to access files on our
> NT server. My code to get the file I want to open is this:
> 
> getfile1 = "..\..\..\..\..\..\nfl\internet\" & random1 & ".132" 
> Set getfile2 = Server.CreateObject("Scripting.FileSystemObject") 
> getfile3 = Server.MapPath(getfile1) 
> Set InStream = getfile2.OpenTextFile(getfile3, 1, False, False)
> I then read the file line by line... 
> 
> The issue at hand is that I need to set this block of code up so that I
> first check to see if it exists, and secondly if it does exist, make sure
> that it is not 0 MB. In this case my ASP page may try and access the file
> before another application is finished creating it - hence the 0 MB rule.
> I need a way of looping to see if the file exists and is not 0 mb. Can
> someone help me with the code/syntax please?????? Please
> 

John Pirkey 
MCSD 
John@S... 
http://www.stlvbug.org

  Return to Index