'  
'   Rebex Sample Code License
' 
'   Copyright 2026, REBEX CR s.r.o.
'   All rights reserved.
'   https://www.rebex.net/
' 
'   Permission to use, copy, modify, and/or distribute this software for any
'   purpose with or without fee is hereby granted.
' 
'   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
'   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
'   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
'   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
'   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
'   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
'   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
'   OTHER DEALINGS IN THE SOFTWARE.
' 

Imports System
Imports System.IO
Imports System.Data
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class [Default]
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        ' get all .zip files from the data directory
        Dim di As New DirectoryInfo(Server.MapPath(Constants.SampleFilesVirtualDirectory))
        Dim files As FileInfo() = di.GetFiles("*.zip")

        ' bind the file list to the grid
        FilesGridView.DataSource = files
        FilesGridView.DataBind()
    End Sub

    ''' <summary>
    ''' Constructs an URL to the page for browsing the details of the ZIP file.
    ''' </summary>
    ''' <param name="zipFileInfo">ZIP archive info.</param>
    ''' <returns>relative url or empty string, never null</returns>
    Protected Function GetUrl(ByVal zipFileInfo As FileInfo) As String
        If zipFileInfo Is Nothing Then
            Return String.Empty
        End If

        Return String.Format("BrowseArchive.aspx?{0}={1}", UrlParameter.ArchiveFileName, Uri.EscapeDataString(zipFileInfo.Name))
    End Function
End Class
