我在Office 365的SkyDrive Pro中的“我的文档”文件夹中有个人文件。
据我了解,SkyDrive Pro使用SharePoint作为后备存储。我可以使用SharePoint API(Microsoft.SharePoint.Client.ClientContex)访问这些文件吗?
我的意思是来自Office 365的SkyDrive Pro。例如,如果你去companyname.sharepoint.com,右边会有菜单:Outlook,Calendar,People,Newsfeed, SkyDrive 。它与SkyDrive的消费者不同。
答案 0 :(得分:1)
是的,您可以像往常一样通过ClientContext访问文件和文件夹信息。唯一的区别是,在构建ClientContext时,您需要使用不同的URL - 您在转到“SkyDrive”选项卡时看到的URL(类似https://companyname-my.sharepoint.com/personal/username_companyname_onmicrosoft_com/)。
如果要以编程方式检索此URL,可以使用以下代码段:
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);
答案 1 :(得分: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();
}