|
 |
asp_web_howto thread: file system object related problem
Message #1 by "taherm@f... on Mon, 24 Sep 2001 15:26:26
|
|
i have a directory called images.
every image is named as same name as their product code
for example product code argent3000 will have an image called
argent3000.gif in teh images directory.
what i wnat to do is to search for a particular product code in teh image
directory. if that image is present tehn it should display the image else
it should display nopic.gif image.
plz let me knw of how can i achieve the above.
i would greatly appreciate any response regarding teh above. thanks very
much in advance
Message #2 by "TomMallard" <mallard@s...> on Mon, 24 Sep 2001 08:42:39 -0700
|
|
Use the folders collection to gain the files collection for that folder. If
you know the drive, etc....
set objFSO = server.createobject("Scripting.FilesSystemObject")
set objFolder = objFSO.GetFolder("Drive:\path to parent folder")
Then you can loop through and compare what you find to the person's file
(strFileName).
for i=0 to objFolder.Files.Count
if (objFolder.Files.Item(strFileName)) then
'found it
else
'display nogif
end if
next
tom mallard
seattle
----- Original Message -----
From: <taherm@f...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Monday, September 24, 2001 3:26 PM
Subject: [asp_web_howto] file system object related problem
> i have a directory called images.
> every image is named as same name as their product code
> for example product code argent3000 will have an image called
> argent3000.gif in teh images directory.
>
> what i wnat to do is to search for a particular product code in teh image
> directory. if that image is present tehn it should display the image else
> it should display nopic.gif image.
>
> plz let me knw of how can i achieve the above.
>
> i would greatly appreciate any response regarding teh above. thanks very
> much in advance
Message #3 by "nick" <nick@i...> on Mon, 24 Sep 2001 16:45:22
|
|
I would think the FileExists method may be quicker than looping through
each image in your folder, not 100% sure though.
If objFSO.FileExists("e:\mywebsite\products\images\myimage.gif") Then
'Found It
Else
'Display nopic.gif
End If
|
|
 |