I am calling a method through ajax. My ajax is working fine.
But it throws compile time error on my code.
Here is my code
[WebMethod]
public static List<string> getDirectoryNames(string dirLocation)
{
string paths = dirLocation;
List<string> dir = new List<string>();
//string getPat = getPath("");
foreach(var dirr in new DirectoryInfo(Server.MapPath(@paths)).GetDirectories()) //error on this **Server**
{
dir.Add(dirr.Name);
}
return dir;
}
I think I cannot declare Server.MapPath on Static method. So what I have to do?