Hi friends here i m using datalist control to display images from folder with name.its working fine but the images name displayed with extension( like .jpg,.png).I want to display only image name without their extension can any one help me out...
here is my code.....
VerticalAlign="Bottom" />
C#:
DirectoryInfo dir = new DirectoryInfo(MapPath("Movies"));
FileInfo[] files = dir.GetFiles();
ArrayList listItems = new ArrayList();
foreach (FileInfo info in files)
{
listItems.Add(info);
}
DataList2.DataSource = listItems;
DataList2.DataBind();
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Dec 3, 2013, 10:52 PM EST
instead of Bind use Eval. following code will deduct last 4 character so the extension will not shown
Kunal VaishyaRank #990 · 2K reputationPosted Dec 3, 2013, 10:58 PM EST
FileInfo[] files = dir.GetFiles();
ArrayList listItems = new ArrayList();
foreach (FileInfo info in files)
{
listItems.Add(info.Name.Substring(0, info.Name.Length - 4));
}
selva kumarRank #2,987 · 483 reputationPosted Dec 4, 2013, 12:24 AM EST