
Hi @Shreeja ,
Have your issue fixed? “The sign-in name or password does not match one in the Microsoft account system” Error will occur sometimes and fixed after a while with nothing changed.
I tested the following code and it runs well:
ClientContext ctx = new ClientContext("https://xxxx.sharepoint.com/sites/xxx");
var strPassword = "*********";
SecureString secureString = new SecureString();
strPassword.ToList().ForEach(secureString.AppendChar);
ctx.Credentials = new SharePointOnlineCredentials("xxxx@****.onmicrosoft.com", secureString);
Web site = ctx.Web;
ctx.Load(site);
ctx.ExecuteQuery();
Console.WriteLine("Title: " + site.Title + "; URL: " + site.Url);
Console.ReadLine();
var filePath = "C:\\Users\\xxxx\\Desktop\\test.txt";
var libraryName = "Doc99";
FileCreationInformation fci = new FileCreationInformation();
fci.Content = System.IO.File.ReadAllBytes(filePath);
fci.Url = Path.GetFileName(filePath);
Web web = ctx.Web;
List targetDocLib = ctx.Web.Lists.GetByTitle(libraryName);
ctx.ExecuteQuery();
Microsoft.SharePoint.Client.File newFile = targetDocLib.RootFolder.Files.Add(fci);
ctx.Load(newFile);
ctx.ExecuteQuery();
So please test your code again. If the error still occurred, our account may be MFA (Multi-factor authentication) enabled. Please follow the steps to disable MFA
https://learn.microsoft.com/en-us/microsoft-365/admin/security-and-compliance/set-up-multi-factor-authentication?view=o365-worldwide
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.