gpt4 book ai didi

sharepoint - 错误代码 : 3604 when deleting file from SharePoint Document Library

转载 作者:行者123 更新时间:2023-12-03 23:57:13 24 4
gpt4 key购买 nike

我正在 SharePoint 2007 中开发 WebPart,有时当我尝试使用如下代码从文档库中删除文件时:


SPWeb web = SPControl.GetContextWeb(WebPart.WebPartContext);

SPList list = web.GetList(web.Site.Url + "/ListName");

SPFile file = list.GetItemByUniqueId(new Guid(fileId)).File;

file.Delete();

我得到以下异常:

Cannot remove file "filename.bmp". Error Code: 3604.<p></p>

Stack Trace:
at Microsoft.SharePoint.Library.SPRequest.AddOrDeleteUrl(String bstrUrl, String bstrDirName, Boolean bAdd, UInt32 dwDeleteOp, Int32 iUserId, Guid& pgDeleteTransactionId)
at Microsoft.SharePoint.SPFile.DeleteCore(DeleteOp deleteOp)
at Microsoft.SharePoint.SPFile.Delete()

SPFile 对象不为空。

知道为什么会这样吗?

最佳答案

我唯一能想到的可能是该文件当前已 checkout 或锁定以供其他用户编辑。试试这个...

SPWeb web = SPControl.GetContextWeb(WebPart.WebPartContext);
SPList list = web.GetList(web.Site.Url + "/ListName");
SPFile file = list.GetItemByUniqueId(new Guid(fileId)).File;

if (file.CheckOutStatus != SPFile.SPCheckOutStatus.None)
{
file.UndoCheckOut();
file.CheckOut();
}

file.Delete();

关于sharepoint - 错误代码 : 3604 when deleting file from SharePoint Document Library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3370471/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com