2013-10-23 87 views
1

我在Office 365中的SkyDrive Pro的「我的文檔」文件夾中有個人文件。是否有可能通過sharepoint clientcontext訪問我的skydrive個人文件?

據我所知,SkyDrive Pro使用SharePoint作爲備份存儲。我可以使用SharePoint API(Microsoft.SharePoint.Client.ClientContex)訪問這些文件嗎?

我的意思是從SkyDrive的Office 365中臨舉例來說,如果你去companyname.sharepoint.com,你將有菜單的右上角:Outlook中,日曆,人物,新聞源,SkyDrive的。對於消費者來說,它與SkyDrive不同。 enter image description here

+1

你試過http://blogs.msdn.com/b/sharepointdev/archive/2013/08/13 /access-skydrive-pro-using-the-sharepoint-2013-apis.aspx?這是關於REST API的,但他們說「CSOM等價物可用」 – ovolko

回答

1

是的,你可以通過ClientContext訪問文件和文件夾的信息如常。唯一的區別是,在構建ClientContext時,您需要使用不同的URL - 您在進入「SkyDrive」選項卡時看到的URL(例如https://companyname-my.sharepoint.com/personal/username_companyname_onmicrosoft_com/)。

如果你想以編程方式檢索該網址,你可以使用下面的代碼片段:

var clientContext = new ClientContext("https://**companyname**-my.sharepoint.com/"); 
clientContext.Credentials = new SharePointOnlineCredentials(**userName**, **password**); 

var props = peopleManager.GetMyProperties(); 

clientContext.Load(props);    
clientContext.ExecuteQuery(); 

Console.WriteLine(props.PersonalUrl); 
0

http://msdn.microsoft.com/en-us/library/office/dn423226.aspx

public static void GetSkyDriveFiles(string path, int rowLimit, string sortExpression) 
    { 
      string queryText = "Path:\""+path+"Documents/*\" IsDocument:1";  
      //string uriTempale = "{0}_api/search/query?querytext='{1}'&rowlimit={2}&sortlist='{3}'"; 
      var clientContext = new ClientContext(@path) 
      { 
        Credentials = "ur credentials"; 
      } 


      cxq.KeywordQuery keywordQuery = new cxq.KeywordQuery(clientContext); 
      keywordQuery.QueryText = queryText; 
      keywordQuery.RowLimit = rowLimit; 
      cxq_ConvertSortExpressionToList(keywordQuery.SortList, sortExpression); 
      //keywordQuery.SortList.Add("Write", cxq.SortDirection.Ascending); 

      cxq.SearchExecutor searchExecutor = new cxq.SearchExecutor(clientContext); 
      ClientResult<cxq.ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery); 
      clientContext.ExecuteQuery(); 
    } 
相關問題