Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   HOWTO compare recordset with a name of a phisical file (http://www.velocityreviews.com/forums/t795401-howto-compare-recordset-with-a-name-of-a-phisical-file.html)

Emilio Mala 07-13-2004 10:12 PM

HOWTO compare recordset with a name of a phisical file
 
Hello everybody!
If you could help he, I appreciate... thanks!
Lets go to the problem:

- I need compare the recordset from a database and check if the file
exists in a directory.
If exists, I show a picture, case not, I dont show....

Sample:
The result from a recordset was "hawai.jpg"
Then I need to check if the file exists in a directory located in
/images/countries/...
IF exists I show the image
IF NOT I show the message "Sorry, this country doesnt have a picture in
the directory."
Thanks in advance!
Best Regards!
Emilio



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bullschmidt 07-14-2004 04:02 AM

Re: HOWTO compare recordset with a name of a phisical file
 
To see if a file exists:
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(MyFilenameVar) Then...

And here are some FSO resources:

FileSystemObject
http://www.4guysfromrolla.com/webtec...leSystemObject
5-part FAQ

Using the FileSystemObject for Web Site Maintenance, Part 2 - 9/14/1999
http://www.4guysfromrolla.com/webtech/091499-1.shtml

Best regards,
J. Paul Schmidt, Classic ASP Web Designer
http://www.Bullschmidt.com
Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Alex Kail 07-14-2004 12:30 PM

Re: HOWTO compare recordset with a name of a phisical file
 
Use this function. The file name must be the path in which it resides
on the machine, not the absolute or relative paths (ie:
c:\images\countrie\hawai.jpg).

Function FileExist(strFileName)

'Declare
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

'Functions returns whether or not the file exists
FileExist = fso.FileExists(strFileName)

'Housekeeping!
Set fso = Nothing

End Function

Here's an example on how I use it:

If FileExist(Server.MapPath("images\countries") & "\hawai.jpg") = True
Then
'This file exists
Else
'This file does not exist
End If


All times are GMT. The time now is 04:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.