Which code segment should you include in the Web Part?

You have a document library named MyDocs. MyDocs has a column named Column1. Column1 is a required column.

You discover that many documents are checked out because users fail to enter a value for Column1.

You need to create a Web Part to delete the documents.

Which code segment should you include in the Web Part?

You have a document library named MyDocs. MyDocs has a column named Column1. Column1 is a required column.

You discover that many documents are checked out because users fail to enter a value for Column1.

You need to create a Web Part to delete the documents.

Which code segment should you include in the Web Part?

A.
foreach (SPCheckedOutFile file in ((SPDocumentLibrary)SPContext.Current.Web.Lists[“MyDocs”]).CheckedOutFiles)
{
file.Delete();
}

B.
foreach (SPItem file in SPContext.Current.Web.Lists[“MyDocs”].Items)
{
if ((file(“CheckOutStatus”) == “CheckOut”))
{
file.Delete();
}
}

C.
foreach (SPListItem file in ((SPDocumentLibrary)SPContext.Current.Web.Lists[“MyDocs”]).Items)
{
if ((file(“CheckOutStatus”) == “CheckOut”))
{
file.Delete();
}
}

D.
foreach (SPCheckedOutFile file in ((SPDocumentLibrary)SPContext.Current.Web.Lists[“MyDocs”]).CheckedOutFiles)
{
file.TakeOverCheckOut();
}

Explanation:
MNEMONIC RULE: “SPCheckedOutFile, file.Delete()”

Represents a checked-out file in a document library or workspace.

SPCheckedOutFile Class
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcheckedoutfile.aspx



Leave a Reply 0

Your email address will not be published. Required fields are marked *