Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string siteURL = ConfigurationManager.AppSettings["siteURL"];
- string userName = ConfigurationManager.AppSettings["userName"];
- string password = ConfigurationManager.AppSettings["password"];
- ClientContext clientContext = new ClientContext(siteURL);
- SecureString securePassword = new SecureString();
- foreach (char c in password.ToCharArray()) securePassword.AppendChar(c);
- clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);
- Web web = clientContext.Web;
- ListCollection listCollection = clientContext.Web.Lists;
- clientContext.Load(
- listCollection,
- lists => lists
- .Include(
- list => list.Title,
- list => list.Hidden,
- list => list.RootFolder.Files)
- .Where(list => !list.Hidden)
- );
- clientContext.ExecuteQuery();
- FileCollection files = listCollection.Where(x => x.Title == "Documents").FirstOrDefault().RootFolder.Files;
- File file = files.Where(x => x.Name == "Excel_File.xlsx").FirstOrDefault();
Add Comment
Please, Sign In to add comment