Code i used is:
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;
Now this returns me the correct path. When I click on url, I am asked to download that one note file. Is there a way in which i can open this sharepoint file online instead of downloading it?
I finded this way
ctx.Load(item.File);
ctx.ExecuteQuery();
Console.WriteLine(item.File.LinkingUrl);
LikingUrl is what you want I thinks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.