Black cats

Black cats

  • NA
  • 3
  • 1.4k

Display images from sub folder

Apr 19 2014 2:10 AM
HI All,
Its Urgent..
Im able to display images from specific image folder. but i need to display images from sub folder too.
 
 
design code:
<table border="0">
<tr>
<td>
<asp:Button ID="btnPrevious" runat="server" Text="<<" Font-Size="small" style="border: 1px solid steelblue;" CausesValidation="false" />
</td>
<td>
<asp:Image ID="Image1" runat="server" Height="300" Width="300" />
<cc1:slideshowextender ID="SlideShowExtender" runat="server" TargetControlID="Image1"
SlideShowServiceMethod="GetImages" ImageTitleLabelID="lblImageTitle" ImageDescriptionLabelID="lblImageDescription"
AutoPlay="true" Loop="true" PlayButtonID="btnPlay" StopButtonText="Stop"
PlayButtonText="Play" NextButtonID="btnNext" PreviousButtonID="btnPrevious">
</cc1:slideshowextender>
</td>
<td>
<asp:Button ID="btnNext" runat="server" Text=">>" Font-Size="small" style="border: 1px solid steelblue;" CausesValidation="false" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Button ID="btnPlay" runat="server" style="border: 1px solid steelblue;" CausesValidation="false" Text="Play" Font-Size="Small" Height="32px" Width="54px" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<br />
<b>Name:</b>
<asp:Label ID="lblImageTitle" runat="server" Text="Label" /><br />
<b>Description:</b>
<asp:Label ID="lblImageDescription" runat="server" Text="Label" />
</td>
</tr>
</table>
front end:
[WebMethod]
[ScriptMethod]
public static Slide[] GetImages()
{
List<Slide> slides = new List<Slide>();
// string path = HttpContext.Current.Server.MapPath("/Image/" + "CurryMasala-11/"); //("~/Image/CurryMasala-11/");
// string path = Server.MapPath("~/Curry Masala/");
string path = HttpContext.Current.Server.MapPath("~/Image/"); //Path.Combine(HttpRuntime.AppDomainAppPath, "~\Image");
if (path.EndsWith("\\"))
{
path = path.Remove(path.Length - 1);
}
Uri pathUri = new Uri(path, UriKind.Absolute);
string[] files = Directory.GetFiles(path);
foreach (string file in files)
{
Uri filePathUri = new Uri(file, UriKind.Absolute);
slides.Add(new Slide
{
Name = Path.GetFileNameWithoutExtension(file),
Description = Path.GetFileNameWithoutExtension(file) + " Description.",
ImagePath = pathUri.MakeRelativeUri(filePathUri).ToString()
});
}
return slides.ToArray();
}

Answers (2)