3
Answers

in slideshow server.mappath not identify the path

[WebMethod]
[ScriptMethod]
public static Slide[] GetImages()
{
List<Slide> slides = new List<Slide>();
string path = HttpContext.Current.Server.MapPath("~/images/");
/*
but while i drag that folder in cs file it is like http://localhost:65185/image/
*/
//Page.ResolveClientUrl(path);
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 (3)