我有一個連接到SharePoint Web服務下面的代碼:SPFolder.Exists如果它確實存在返回false
string response = string.Empty;
SPSecurity.RunWithElevatedPrivileges(new SPSecurity.CodeToRunElevated(delegate()
{
using (SPSite spsite = new SPSite("http://sharepoint/"))
{
using (SPWeb spweb = spsite.OpenWeb("sites/" + site))
{
spweb.AllowUnsafeUpdates = true;
SPFolder spfolder = spweb.GetFolder(path);
/* The following value will always be set to FALSE
* but the next time spfolder.Exists is called, the
* returned value will be true.
*/
//bool exists = spfolder.Exists;
if (spfolder == null || !spfolder.Exists)
response = "Folder Does Not Exist!";
else
response = "Folder Exists!";
}
}
}
return response;
如果我調試它,因爲它是上面的代碼工作完全正常步逐從頂部開始。如果我在沒有調試的情況下運行它,或者稍後在代碼中放置了斷點,則SPFolder.Exists值始終設置爲false,實際上,它應該是true。如果我取消上述bool exists
行的註釋,那麼它將正常工作。
我在這裏做錯了嗎?
嗯,是的,它只是SharePoint中。 :-) –