- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Security;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.SharePoint.Client;
-
- namespace CheckListItem
- {
- class Program
- {
- static void Main(string[] args)
- {
- string userName = "[email protected]";
- string siteURL = "https://c986.sharepoint.com/sites/Vijai";
- Console.WriteLine("Enter your password.");
- SecureString password = GetPassword();
-
-
- using (var clientContext = new ClientContext(siteURL))
- {
-
- clientContext.Credentials = new SharePointOnlineCredentials(userName, password);
-
-
- Web web = clientContext.Web;
-
-
- List list = web.Lists.GetByTitle("Documents");
-
-
- ListItem item = list.GetItemById(17);
-
-
- clientContext.Load(item);
-
-
- clientContext.ExecuteQuery();
-
-
- if (item.FileSystemObjectType == FileSystemObjectType.File)
- {
- Console.WriteLine("List item is a file.");
- }
-
- Console.ReadLine();
- }
- }
-
- private static SecureString GetPassword()
- {
- ConsoleKeyInfo info;
-
- SecureString securePassword = new SecureString();
- do
- {
- info = Console.ReadKey(true);
- if (info.Key != ConsoleKey.Enter)
- {
- securePassword.AppendChar(info.KeyChar);
- }
- }
- while (info.Key != ConsoleKey.Enter);
- return securePassword;
- }
- }
- }