我正在開發一個Web部件在SharePoint 2007中,有時當我嘗試刪除文檔庫文件有這樣的代碼:錯誤代碼:3604從SharePoint文檔庫中刪除文件時
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.
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對象不爲空。
任何想法爲什麼發生這種情況?
謝謝你的建議。當我收到異常時,我嘗試了上面的代碼,而CheckOutStatus是None。它適用於刪除SharePoint Web界面中的文件,但不適用於API。 – igorti 2010-09-08 15:03:27