questa è la procedura che genera le miniature
Sub EventHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim path As String = Request.PhysicalApplicationPath & "public\" & sender.text
Dim nomeFile As String = String.Empty
Dim currentDir As String = String.Empty
Dim foto As ImageButton = Nothing
Dim image1 As Drawing.Bitmap
Dim l As Int16 = 0
Dim h As Int16 = 0
divContent.Visible = True
content.Controls.Clear()
lblTitolo.Text = "Foto di " & Split(path, "\")(UBound(Split(path, "\"))) & "<br /><br />"
lblTitolo.CssClass = "titolo"
lblTitolo.Visible = True
Dim i As Integer = 0
'ciclo delle foto e del file zip
For Each fileElement As String In Directory.GetFiles(path)
'cerco il file .zip
Dim currentFile As String = Split(fileElement, "\")(UBound(Split(fileElement, "\")))
Dim estensione As String = Split(currentFile, ".")(UBound(Split(currentFile, ".")))
zipContent.Visible = False
currentDir = Split(path, "\")(UBound(Split(path, "\")))
If estensione = "zip" Then
zipContent.Visible = True
Dim fileZip As New HyperLink
fileZip.NavigateUrl = "download.aspx?zip=" & currentFile & "&name=" & currentDir
fileZip.ID = currentFile
fileZip.ImageUrl = "img\btnScaricafoto.jpg"
zipContent.Controls.Add(fileZip)
Else
'genero le miniature delle foto
foto = New ImageButton
foto.ImageUrl = "public\" & currentDir & "\tnb\" & "\" & fileElement.Split("\")(UBound(fileElement.Split("\")))
foto.PostBackUrl = "dettaglio.aspx?img=" & currentDir & "\" & fileElement.Split("\")(UBound(fileElement.Split("\")))
foto.ID = i
'foto.Width = 50
image1 = New Drawing.Bitmap(path & "\" & fileElement.Split("\")(UBound(fileElement.Split("\"))), True)
If image1.Width > image1.Height Then
'orizzontale
l = 110
h = 74
foto.Width = l
foto.Height = h
Else
'verticale
h = 110
l = 74
foto.Width = l
foto.Height = h
End If
foto.CssClass = "foto"
content.Controls.Add(foto)
i = i + 1
End If
Next
End Sub