I am having file binary data and I want to create File with this blob data into SharePoint 2010.

I am using CSOM(C#) to interact with SharePoint 2010.

I am able to create all the files successfully with the help of following code:

using (ClientContext clientContext = new ClientContext(siteUrl))
    List documentLibrary = clientContext.Web.Lists.GetByTitle(documentLibraryName);

    FileCreationInformation fileCreationInformation = new FileCreationInformation();
    fileCreationInformation.Content = fileContent;
    fileCreationInformation.Overwrite = true;
    fileCreationInformation.Url = "Url of File";
    Microsoft.SharePoint.Client.File uploadFile = documentLibrary.RootFolder.Files.Add(fileCreationInformation);

But when I am creating *.DAT file, it gives me error

The remote server returned an error: (400) Bad Request.

This file extension is already allowed from Central Administration. While I am uploading the *.DAT file from browser its uploading successfully.

So can any one figure out why it is giving "The remote server returned an error: (400) Bad Request." through code?

Any Help would be appreciable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.