以下为引用的内容:
Sub Page_Load(sender as Object, e as EventArgs)
'Get list of images
Dim dirInfo as New DirectoryInfo(Server.MapPath(""))
Dim images() as FileInfo = FilterForImages(dirInfo.GetFiles())
...
End Sub
以下为引用的内容:
Function FilterForImages(images() as FileInfo) as FileInfo()
Dim newImages as New ArrayList(images.Length)
Dim i as Integer
For i = 0 to images.Length - 1
If Path.GetExtension(images(i).Name) = ".jpg" OrElse _
Path.GetExtension(images(i).Name) = ".jpeg" OrElse _
Path.GetExtension(images(i).Name) = ".png" OrElse _
Path.GetExtension(images(i).Name) = ".gif" then
newImages.Add(images(i))
End If
Next
Return CType(newImages.ToArray(GetType(FileInfo)), FileInfo())
End Function
以下为引用的内容:
Sub Page_Load(sender as Object, e as EventArgs)
...
' Dim imgIndex as Integer = 0
If Not Request.QueryString("N") is Nothing AndAlso _
IsNumeric(Request.QueryString("N")) then
imgIndex = CInt(Request.QueryString("N"))
End If
currentImgTitle.Text = "You are Viewing: " & _
Path.GetFileNameWithoutExtension(images(imgIndex).Name) & _
" (" & imgIndex + 1 & " of " & images.Length & ")"
currentImg.ImageUrl = Path.GetFileName(images(imgIndex).Name)
...
End Sub