I am trying to make a simple photo gallery website. Using ASP.NET and C#. Right now I don\'t have a server set up but I am just using the development one that Visual Studio
For instance
You need to have a way to specify where your images will be stored in your app. Therefore you need a web config file with the path in it. Or if you want to be really creative, you can store it in a database....
In your Web Page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Images.aspx.cs" Inherits="ImageViewer" %>
Viewer Demo
In your web.config
and In your code behind .cs file You really need to filter files, that way if someone( maybe you ;) ) puts erroneous files in it, you won't inadvertently include them...
string filters = "*.jpg;*.png;*.gif";
string Path = ConfigurationManager.AppSettings["FilePath"].ToString();
List images = new List();
foreach (string filter in filters.Split(';'))
{
FileInfo[] fit = new DirectoryInfo(this.Server.MapPath(Path)).GetFiles(filter);
foreach (FileInfo fi in fit)
{
images.Add(String.Format(Path + "/{0}", fi));
}
}
RepeaterImages.DataSource = images;
RepeaterImages.DataBind();