Monday, February 28, 2011

Iterating through SharePoint Document library and get File info

SPWeb oSpWeb = SPContext.Current.Web;
SPFolder oSPF = oSpWeb.Lists["Shared Documents"].RootFolder;

foreach (SPFile oSPfile in oSPF.Files)
{
if (oSPfile.CheckOutType == SPFile.SPCheckOutType.None)
{
LiteralControl ltc= new LiteralControl(string.Format("
File {0} : {1} : {2}", oSPfile.Name,"Not Checked Out", oSPfile.CheckInComment));
this.Controls.Add(ltc);

}
else
{
LiteralControl ltc= new LiteralControl(string.Format("
File {0} : {1} : {2}", oSPfile.Name,"Checked Out", oSPfile.CheckInComment));
this.Controls.Add(ltc);
}

}

No comments: