Slider of images in an ASP.NET Visual Basic folder

0

How can I show images in slideshow that are in a specific folder, regardless of whether they can be modified in number or name of these.

is in ASP.NET - Visual Basic

I have the code to upload the images to the folder and delete them, which is the following:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        MuestraDatos()
    End Sub

    Private Sub MuestraDatos()
        Dim d As New DirectoryInfo(MapPath("~/slider/"))
        Dim r As FileInfo() = d.GetFiles()
        Dim dt As New DataTable()
        dt.Columns.Add("path")

        For i As Integer = 0 To r.Length - 1
            Dim row As DataRow = dt.NewRow()
            row("path") = "~/slider/" + r(i).Name
            dt.Rows.Add(row)
        Next
        DataList1.DataSource = dt
        DataList1.DataBind()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        If FileUpload1.HasFile Then
            Dim path1 As String = "~/slider/" + Guid.NewGuid().ToString() + "" + Path.GetExtension(FileUpload1.FileName)
            FileUpload1.SaveAs(MapPath(path1))
            Response.Write("Imagen guardada")
            MuestraDatos()
        End If
    End Sub

    Protected Sub LinkButton1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
        File.Delete(MapPath(e.CommandArgument.ToString()))
        Response.Write("Imagen eliminada satisfactoriamente")
        Response.Redirect(HttpContext.Current.Request.Url.ToString(), True)
    End Sub
    
asked by Francisco 16.08.2017 в 14:46
source

0 answers