PDA

View Full Version : asp.net: check if image exists & save automatically


david7777
05-08-2003, 11:50 AM
Is it possible to do the following:

I have a domain "www.domain2.net"
I have a seperate domain with files on it. (www.domain1.com)

I know there is a folder www.domain1.com/thumbnails/.
In the thumbnails folder, the images are named 1.gif, 2.gif etc...

So i know the file name and path, but the problem is that i dont know how many images there are. So i want to use an infinite loop, and in each loop, a variable will increase by one. I will map a path to the image and check to see if it exists. (1.gif) If it does, save it to disk, and continue with next loop.(2.gif) If it does not exist, exit the loop completely.

ie:

dim i = 1
dim str as string = "http://www.domain1.com/thumbnails/"
dim newStr as String

do
newStr = str & i & ".gif"
' Map to file and check if it exists
if fileExists then
' save file to disk
else
'exit loop
end if
end do


Any help appreciated!

david7777
05-12-2003, 10:40 AM
Does no one know what im talking about, or is it just not possible?

angiras
05-12-2003, 11:03 AM
Public Shared Function ExistFile(ByVal folder As String, ByVal file As String, ByVal Extens As String) As Boolean
If File.Exists(HttpContext.Current.Request.PhysicalApplicationPath + folder + file + Extens) Then
Return True
Else
Return False
End If
End Function