your question is a little bit vague, but I think I got the thing you're looking for. Anyway I'm going to assume you're using ASP.NET, first step is to create something to display your files. I've used a repeater with only a hyperlink in it like so:
<asp:Repeater ID="rpt" runat="server" OnItemDataBound="rpt_ItemDataBound">
<ItemTemplate>
<asp:HyperLink ID="hyp" runat="server" />
</ItemTemplate>
</asp:Repeater>
After this you'll need to fill up the repeater. You can do that in the pageload like this:
if (!Page.IsPostBack)
{
string[] files = Directory.GetFiles(@"C:\testfolder");
rpt.DataSource = files;
rpt.DataBind();
}
Next step you can do is complete the ItemDataBound method like so:
protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
string file = e.Item.DataItem as string;
HyperLink hyp = e.Item.FindControl("hyp") as HyperLink;
hyp.Text = file;
hyp.NavigateUrl = string.Format("~/Handlers/FileHandler.ashx?file={0}", file);
}
}
As you can see in the navigate url, we're going to use an HttpHandler. When you create a new Handler file (.ashx). In its ProcessRequest method you will need something like this, so the file is avaible for downloading:
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.ContentType = "application/octet-stream";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + context.Request.QueryString["file"]);
context.Response.WriteFile(context.Request.QueryString["file"]);
context.Response.End();
}
Don't forget to register your handler in the web.config in the system.web node like so:
<httpHandlers>
<add verb="*" path="~/Handlers/FileHandler.ashx?file={0}" type="StackOverflow.Questions.Handlers.FileHandler, StackOverflow.Questions"/>
</httpHandlers>
Please keep in mind that passing paths through the query string like I did shouldn't be done, but I don't know how your application is working so find something that suits you.
Good luck!