Get the document names from document library in sharepoint using C#

  • Thread starter Thread starter abhijeet.tale
  • Start date Start date
A

abhijeet.tale

I am a newbie to .NET programming. I need to get the names of the
documents in the document library in a particular sharepoint site. Is
the code below correct?


SPSite site = new SPSite("http://server/itteam/rpm");
SPWeb web = site.AllWebs["http://server/itteam/rpm"];

SPDocumentLibrary docLib = (SPDocumentLibrary)web.Lists["Shared
Documents"];
SPListItemCollection items = docLib.Items;
foreach (SPListItem item in items)
{
Console.WriteLine(item.File.Name);
}

I am getting a runtime error as below:

An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll
Additional information: File or assembly name
Microsoft.SharePoint.intl, or one of its dependencies, was not found.

Also I need to know how do I specify the credentials for the server
login in the code. Any help is greatly appreciated.

Thanks.
 
Back
Top