//  
//   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.
// 

using System;
using System.IO;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Rebex.Samples
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // get all .zip files from the data directory
            DirectoryInfo di = new DirectoryInfo(Server.MapPath(Constants.SampleFilesVirtualDirectory));
            FileInfo[] files = di.GetFiles("*.zip");

            // bind the file list to the grid
            FilesGridView.DataSource = files;
            FilesGridView.DataBind();
        }

        /// <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 string GetUrl(FileInfo zipFileInfo)
        {
            if (zipFileInfo == null)
                return string.Empty;

            return string.Format("BrowseArchive.aspx?{0}={1}", UrlParameter.ArchiveFileName, Uri.EscapeDataString(zipFileInfo.Name));
        }
    }
}
