2012-05-24 32 views
-2

我意識到這是一個愚蠢的問題,但MSDN不能從我的網絡"Server Error: 502 - Web server received an invalid response while acting as a gateway or proxy server."訪問,我不能坐在這裏玩弄我的拇指。的SPSite類 - MSDN文檔

我不知道有替代MSDN的,和我的本地Visual Studio幫助的事情不會對這一類事情。

請有人複製並粘貼Microsoft.SharepointSPSite類,特別是構造函數的條目,但整個文章將是有用的。 我得到一個FileNotFoundException並需要知道URL屬性應該如何格式化。

如果你們中的任何人碰巧知道。

public Dictionary<string, SPFolder> GetFolderCollection(string siteURL, string docLibraryName) 
    { 
     using (SPSite oSite = new SPSite(siteURL + ":23179")) 
     { 
      SPWeb oWeb = oSite.OpenWeb(); 
      SPList oList = oWeb.Lists[docLibraryName]; 

      SPFolderCollection oFolders = oList.RootFolder.SubFolders; 

      foreach (SPFolder folder in oFolders) 
      { 
       foundFolders.Add(folder.Name, folder); 
      } 
      return foundFolders; 
     } 
    } 

編輯:乾杯,谷歌緩存ftw。

對於我指着IIS站點根目錄,而不是在SharePoint「網站」的記錄。混淆Sharepoint術語。

+4

而不是把它在計算器上,你爲什麼不只是看一個(http://webcache.googleusercontent.com/搜索?q =緩存:kbp3ROKhyrgJ:msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite.aspx+Microsoft.Sharepoint.SPSite&cd=1&hl=zh-CN&ct=clnk&gl=us&client=safari)此「問題」非常本地化。 – vcsjones

+0

好喊,把這個作爲答案。 – Amicable

+1

http://stackoverflow.com/questions/10739361/msdn-is-down-is-there-a-way-to-search-a-cache-of-its-content – JoelFan

回答

3

表示Web應用程序中的網站集合,包括 頂級網站及其所有子網站。每個SPSite對象,或網站 集合,是一種SPSiteCollection對象 包括在Web應用程序 所有網站集的集合中表示。

繼承層次結構

System.Object的
Microsoft.SharePoint.SPSite

名字空間:

Microsoft.SharePoint程序

裝配:Microsoft.SharePoint程序(在 Microsoft.SharePoint.dll的)

沙盒解決方案中可用:是

可在SharePoint Online中

[SubsetCallableTypeAttribute] [ClientCallableTypeAttribute(名稱= 「網站」,ServerTypeId = 「{E1BB82E8-0D1E-4e52-B90C-684802AB4EF6}」)] 公共類的SPSite:IDisposable的

備註

要實例特定網站集的SPSite對象的 ASP.NET頁面上,或者控制檯 應用程序中的特定網站集,使用SPSite的構造函數如下:C#VB

SPSite oSiteCollection =新的SPSite(「Absolute_URL」);

在ASP.NET應用程序,你可以使用 SPContext類的網站屬性返回表示當前 網站集的SPSite對象,如下所示:C#

的SPSite oSiteCollection = SPContext.Current。現場;

使用SPWebApplication類的Sites屬性返回 SPSiteCollection對象,該對象表示SharePoint Web應用程序中的站點集合 集合。使用索引器從集合中返回單個網站集的 。例如,如果將網站集的 集合分配給名爲 的變量oSiteCollections,請在C#中使用oSiteCollections [index],或者在Visual Basic中使用 oSiteCollections(索引),其中索引爲 顯示名稱或索引編號 集合中的網站集。

某些對象實現了IDisposable接口,並且您必須 避免將這些對象保留在內存中,因爲它們不再需要 。如果創建自己的SPSite對象,則可以使用Dispose 方法關閉對象。您也可以改爲實現使用 語句,以便.NET Framework公共語言運行時(CLR) 自動釋放用來存儲網站 收集如下內存:使用(SPSite的oSiteCollection C#VB

=新的SPSite(「Absolute_URL」){ ...}

不過,如果你有一個參考,以共享資源,當 對象被Web部件的GetContextSite方法提供了諸如,做 也不使用方法來關閉對象。使用 共享資源上的任何一種方法都會導致發生訪問衝突錯誤。在 的情況下,您有一個對共享資源的引用,而不是讓 Microsoft SharePoint Foundation或您的門戶網站應用程序管理 對象。

有關良好編碼實踐的更多信息,請參閱處置 對象。

重要

如果您安裝爲Windows SharePoint Services 3.0 (KB951695)基礎結構更新,如果他們調用SharePoint對象模型模擬的同時暫停定製的解決方案可能會失敗。如果您使用Windows 身份驗證,並且您的代碼從 Internet信息服務(IIS)工作進程調用SharePoint對象模型,則請求必須 模擬調用用戶的身份。 SharePoint Foundation 將ASP.NET配置爲自動模擬主叫用戶,但 代碼可能會意外地工作或失敗,如果您暫停 模擬 - 例如,通過調用Windows API的RevertToSelf功能 ,或通過調用 System.Security.Principal.WindowsIdentity.Impersonate方法和 將IntPtr.Zero作爲用戶標記參數的值傳遞。即使 您的代碼沒有明確地恢復爲自我,它可能會在ASP.NET恢復爲self後調用,例如在實現 虛擬路徑提供程序時發生;如果您的代碼不模擬呼叫 用戶,則可能無法正常運行。

線程安全

此類型的任何公共靜態 (共享在Visual Basic)成員都是線程安全的。任何 實例成員不保證是線程安全的。

構造函數:?在網頁的谷歌緩存版本]

Name Description 
Public method SPSite(Guid) Initializes a new instance of the SPSite class based on the specified ID for a site collection. 
Public method SPSite(String) Initializes a new instance of the SPSite class based on the specified URL. 
Public method SPSite(Guid, SPUrlZone)  Initializes a new instance of the SPSite class based on the specified site collection GUID and URL zone. 
Public method SPSite(Guid, SPUserToken) Initializes a new instance of the SPSite class based on the specified site collection GUID and user token. 
Public method SPSite(String, SPUserToken)  Initializes a new instance of the SPSite class based on the specified absolute URL and user token. 
Public method SPSite(Guid, SPUrlZone, SPUserToken) Initializes a new instance of the SPSite class based on the specified site collection GUID, URL zone, and user token.