我能够显示特定文件夹中的图像。但我需要从子文件夹显示图像。 [英] I'm Able To Display Images From A Specific Folder. But I Need To Display Images From Sub Folder Too.

查看:57
本文介绍了我能够显示特定文件夹中的图像。但我需要从子文件夹显示图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大师,

紧急.....

请在下面找到我的代码

-------- --------------------





Hi gurus,
Its urgent.....
PLease find my code below
----------------------------


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();
}

推荐答案

这篇关于我能够显示特定文件夹中的图像。但我需要从子文件夹显示图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆