Re: file size (or existence) determination in ASP

by "Nik Krimm" <nik(at)krimm.net>

 Date:  Tue, 17 Apr 2001 11:56:49 -0500
 To:  "Shull,
Conrad" <cshull(at)shscares.org>,
<hwg-languages(at)hwg.org>
 References:  ntmail1
  todo: View Thread, Original
Hi Conrad:
If you are using vbscript serverside, these should work for you.  Use the
fileSystemObject, which actually has a method "FileExists"  There is also a
script for finding the file size below if you want that as well.


'@  find out if file 'filespec' exists
'@ call by using i.e. ReportFileStatus("C:\images\neat.gif")

Function ReportFileStatus(filespec)
   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FileExists(filespec)) Then
      msg = filespec & " exists."
   Else
      msg = filespec & " doesn't exist."
   End If
   ReportFileStatus = msg
End Function


'@ this function shows the size of file 'filespec'
Function ShowFolderSize(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(filespec)
   s = UCase(f.Name) & " uses " & f.size & " bytes."
   ShowFolderSize = s
End Function


Hope this helps

----- Original Message -----
From: "Shull, Conrad" <cshull(at)shscares.org>
To: <hwg-languages(at)hwg.org>
Sent: Tuesday, April 17, 2001 10:04 AM
Subject: file size (or existence) determination in ASP


> Greetings,
>
> I'd like to be able to determine the file size of an image [ <img
> src="image.jpg"> ] in an ASP.  Actually, I just want to be able to
determine
> whether the file exists or not (perhaps via its file size), so I can
> substitute another image file in the webpage if it doesn't.  Any ideas?
>
> - Conrad Shull
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA