0

I'm using Microsoft.SharepointOnline.CSOM nugget and I can upload files withput any problems but if I change to ExecuteQueryAsync() method seems to be notworking. Simply program fails without any exception.

Code Example

FileCreationInformation fileCreation = new FileCreationInformation()
{
    ContentStream = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(file.SourceFilePath)),
    Overwrite = true,
    Url = file.FileName
};
var uploadFile = folder.Files.Add(fileCreation);
_clientContext.Load(uploadFile);
await _clientContext.ExecuteQueryAsync();

Same code using ExecuteQuery() is working properly.

3
  • Have you tried to add try-catch? try{await _clientContext.ExecuteQueryAsync();}catch(Exception ex){} Commented May 6, 2024 at 5:18
  • Yes, I have tried with try cath. The problem is that async seems to be not supported in console applications Commented May 18, 2024 at 21:39
  • Could you share the whole method and how do you call the method? Commented May 19, 2024 at 12:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.