簡體   English   中英

我正在嘗試在sharepoint中搜索文件

[英]I am trying to search for a file in sharepoint

我使用的代碼是:

List<ScenarioModel> result = new List<ScenarioModel>();

            string webUrl = "https://microsoft.sharepoint.com/teams/ABCD/EFGHI";

            string userName = System.Configuration.ConfigurationManager.AppSettings["userName"];

            SecureString password = ConvertToSecureString(System.Configuration.ConfigurationManager.AppSettings["userPassword"]);

            using (ClientContext ctx = new ClientContext(webUrl))
            {
                ctx.Credentials = new SharePointOnlineCredentials(userName, password);
                Web web = ctx.Web;
                ctx.Load(web);
                Microsoft.SharePoint.Client.List docList = web.Lists.GetByTitle("Documents");
                ctx.Load(docList);

                KeywordQuery keywordQuery = new KeywordQuery(ctx);
                keywordQuery.QueryText = queryText;

                SearchExecutor searchExecutor = new SearchExecutor(ctx);

                ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);

                ctx.ExecuteQuery();
                foreach (var resultRow in results.Value[0].ResultRows)
                {
                    ScenarioModel modelObject = new ScenarioModel();
                    modelObject.Path = resultRow["Path"];
                    modelObject.Title = resultRow["Title"].ToString();
                    result.Add(modelObject);
                }
            }

            return result;

現在,這為我返回了正確的路徑。 當我單擊url時,要求我下載該注釋文件。 有沒有一種方法可以使我在線打開該共享點文件而不是下載它?

我發現這樣

                            ctx.Load(item.File);
                        ctx.ExecuteQuery();
                        Console.WriteLine(item.File.LinkingUrl);

我想LikingUrl是您想要的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM