SPList list = web.GetList(strUrl);
foreach (SPListItem item in list.Items)
{
SPFile sourceFile = item.File;
if ((sourceFile.Level == SPFileLevel.Draft) && (sourceFile.CheckOutStatus == SPFile.SPCheckOutStatus.None))
{
sourceFile.Publish("File Automatically Bulk Published");
try
{
if
(sourceFile.Item.ModerationInformation.Status ==
SPModerationStatusType.Pending)
{
sourceFile.Approve("File Automatically Approved During Bulk Publish");
}
}
catch (System.Exception)
{
//Suppress
}
sourceFile.Update();
}
}
|