I am trying to search a document library for a specific document. I am fairly new to sharepoint and cannot figure out how to retrieve the document.
Below is my code:
private void button12_Click(object sender, EventArgs e) { using (var site = new SPSite(SiteUrl)) { if (SiteUrl != null) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["Documents"]; if (list != null) { foreach (SPListItem item in list.Items) { if (item.Name.Any() == textBox1.ToString().Any()) listBox1.Items.Add("Document Found"); else listBox1.Items.Add("Cannot Find Document"); } web.Close(); } site.Close(); } } } }