That is a part of a Visible Studio 2017 software being developed on a Home windows 10 field. Right here is my code. I’ve tried numerous configurations however the consequence stays the identical. Unsure the place to go from right here.
personal string SaveFile(string fileName, byte[] fileContent)
{
string retVal = string.Empty;
attempt
{
string spSiteUrl = "https://<mysite>.sharepoint.com/SitePages/TestFiles";
string username = Convert.ToString(ConfigurationManager.AppSettings["KeyUserName"]);
string password = Convert.ToString(ConfigurationManager.AppSettings["KeyPassword"]);
utilizing (ClientContext cnx = new ClientContext(spSiteUrl))
{
SecureString secret = new SecureString();
foreach (char c in password)
{
secret.AppendChar(c);
}
cnx.Credentials = new SharePointOnlineCredentials(username, secret);
Net w = cnx.Net;
cnx.Load(w, web site => web site.Lists, web site => web site.ServerRelativeUrl);
cnx.ExecuteQuery();
retVal = "Success";
}
}
catch (Exception ex)
{
MessageBox.Present(ex.Message + Surroundings.NewLine + ex.InnerException);
}
return retVal;
}