In this function fill's in an ArrayList with all available Lists on a Site using the SharePoint
Webservice Lists.asmx .
Little remark, a document library is also a list and will also be returned by the webservice.
private void GetLists(string myurl, ArrayList myAList)
{
SetStatus("Initialize webservice...");
myAList.Clear();
WS_Lists.Lists lists = new WS_Lists.Lists();
if (chk_DefaultLoggin.Checked)
lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
else
{
lists.PreAuthenticate = true;
lists.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
}
lists.Url = myurl + @"/_vti_bin/lists.asmx";
try
{
this.SetStatus("Getting lists for site " + myurl);
XmlNode myNode = lists.GetListCollection();
XmlNodeList nodes = myNode.SelectNodes("*");
foreach (XmlNode node in nodes)
{
myAList.Add(node.Attributes["Title"].Value);
}
}
catch (Exception exception1)
{
MessageBox.Show(exception1.Message, "Error loading list info", MessageBoxButtons.OK);
this.SetStatus("Error loading list info");
}
finally
{
lists.Dispose();
}
}
Geen opmerkingen:
Een reactie posten