Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
File Not Found Error When Uploading Files to Sharepoint

I am getting the File Not Found exception in the ExecuteQuery() method but the file is sitting there in the mentioned folder.

I have included my code below. I am working on a .NET core application.

FileCreationInformation newFile = new FileCreationInformation();
newFile.Url = System.IO.Path.GetFileName(filePath);
newFile.Content = System.IO.File.ReadAllBytes(filePath);

Folder library = SPClientContext.Web.Folders.GetByUrl(fullFolderUrl);
Microsoft.SharePoint.Client.File uploadFile = library.Files.Add(newFile);
SPClientContext.Load(uploadFile);
SPClientContext.ExecuteQuery();



Microsoft.SharePoint.Client.ServerException
  HResult=0x80131500
  Message=File Not Found.
  Source=Microsoft.SharePoint.Client.Runtime
  StackTrace:
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
   at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
   at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
   at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
   at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
   at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
   at SharePointTest.Program.<Main>d__0.MoveNext() in C:\Users\O
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You need to at least call Load and ExecuteAsync method after you call GetByUrl method on library

FileCreationInformation newFile = new FileCreationInformation();
newFile.Url = System.IO.Path.GetFileName(filePath);
newFile.Content = System.IO.File.ReadAllBytes(filePath);

Folder library = SPClientContext.Web.Folders.GetByUrl(fullFolderUrl);
SPClientContext.Load(library);
SPClientContext.ExecuteQuery();
var files = library.Files;
SPClientContext.Load(files);
SPClientContext.ExecuteQuery();
Microsoft.SharePoint.Client.File uploadFile = files.Add(newFile);
SPClientContext.Load(uploadFile);
SPClientContext.ExecuteQuery();
over 4 years ago · Santiago Trujillo Denunciar

0

Please check whether the path of the file you need to upload is correct , then check the path of “fullFolderUrl” , you need to fill in the exact path of the specific library that you want to upload to.

Here is an example that will upload a file to SharePoint library:

static void Main(string[] args)
{
     string filePath = "C:\\Users/Administrator.SP01/Desktop/New folder/test.xlsx";
     string fullFolderUrl = "https://abc.sharepoint.com/sites/xxx/LibraryTest";
     var SPClientContext = GetonlineContext();
     Web web = SPClientContext.Web;
            
     FileCreationInformation newFile = new FileCreationInformation();
     newFile.Url = System.IO.Path.GetFileName(filePath);
     newFile.Content = System.IO.File.ReadAllBytes(filePath);

     Folder library = SPClientContext.Web.Folders.GetByUrl(fullFolderUrl);
     Microsoft.SharePoint.Client.File uploadFile = library.Files.Add(newFile);
     SPClientContext.Load(uploadFile);
     SPClientContext.ExecuteQuery();
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda