Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. MuestraDatos()
  3. End Sub
  4.  
  5. Private Sub MuestraDatos()
  6. Dim d As New DirectoryInfo(MapPath("~/slider/"))
  7. Dim r As FileInfo() = d.GetFiles()
  8. Dim dt As New DataTable()
  9. dt.Columns.Add("path")
  10.  
  11. For i As Integer = 0 To r.Length - 1
  12. Dim row As DataRow = dt.NewRow()
  13. row("path") = "~/slider/" + r(i).Name
  14. dt.Rows.Add(row)
  15. Next
  16. DataList1.DataSource = dt
  17. DataList1.DataBind()
  18. End Sub
  19.  
  20. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
  21. If FileUpload1.HasFile Then
  22. Dim path1 As String = "~/slider/" + Guid.NewGuid().ToString() + "" + Path.GetExtension(FileUpload1.FileName)
  23. FileUpload1.SaveAs(MapPath(path1))
  24. Response.Write("Imagen guardada")
  25. MuestraDatos()
  26. End If
  27. End Sub
  28.  
  29. Protected Sub LinkButton1_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
  30. File.Delete(MapPath(e.CommandArgument.ToString()))
  31. Response.Write("Imagen eliminada satisfactoriamente")
  32. Response.Redirect(HttpContext.Current.Request.Url.ToString(), True)
  33. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement