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:
SlideShowServiceMethod=" AutoPlay="true" Loop="true" PlayButtonID="btnPlay" StopButtonText="Stop" PlayButtonText="Play" NextButtonID="btnNext" PreviousButtonID="btnPrevious" | ||
Name: Description: | ||
front end:
[WebMethod]
[ScriptMethod]
public static Slide[] GetImages()
{ List slides = new List();
// 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();
}2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Black catsPosted Apr 20, 2014, 1:32 AM
Munesh SharmaPosted Apr 19, 2014, 3:39 PM
The ResolveClientUrl method will automatically resolve the correct path starting off from the root of the app (~/)