0

I am making a app for SharePoint Online and in the app I have a function that deletes documents in a folder. But if someone have the document open or if the document is checked out the app crashes because the document the app cant get the document but its there. When i try to remove the "currently edited" document I get a error

"The file is currently checked out or locked for editing by another user"

And I cant remove the document for couple of hours. So is there a way to force delete a file/document in SharePoint Online by code? At the moment I use the code below to delete a folder.

foreach (Folder f in fcol)
{
    if (f.Name == pDeleteRequest.RfcId)
    {
        f.DeleteObject();
        break;
    }
}
0

Something you can try is undoing the checkout before you try to delete it. You could write a function and do a security override to check if the item is checked out. and if it is, check it in and the try your delete function. If you are deleting it anyways, then who cares if it is checkout or not right? Override it and then kill it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.