To get the list of all the fields in
the list we can create a simple console application. In this console
application we can pass the site URL & provide the Name of the list of
whose field details we want to use.
string siteUrl =
"http://sitename ";
// ClientContext object is
used to get the context for the SharePoint objects
string ListName = "/ListName";
//ClientContext
clientcontext = new ClientContext(siteUrl);
SPSite site = new SPSite(siteUrl);
Console.WriteLine(site.ToString()
+ "\n");
SPWeb web =
site.OpenWeb();
SPList list =
web.GetList(string.Concat(web.Url, ListName));
Console.WriteLine(list.ToString()
+ "\n");
//SPList list =
web.Lists["Users"];
foreach (SPField f in
list.Fields)
{
Console.WriteLine(f.StaticName.ToString()
+ " - " +
f.TypeDisplayName.ToString() + "\n");
}
Console.ReadLine();
No comments:
Post a Comment