C# CSOM OpenBinaryDirect not working for files contains # in their name.

Amit 731 Reputation points
2022-03-07T12:28:34.593+00:00

Below code not working if file name contains #.

var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, fileRef);

Thanks.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,810 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tong Zhang_MSFT 9,141 Reputation points
    2022-03-08T06:23:24.07+00:00

    Hi @Amit ,
    Special characters are not supported on CSOM .Here is a related document you can look at:
    https://support.microsoft.com/en-us/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa?ui=en-us&rs=en-us&ad=us


    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.



1 additional answer

Sort by: Most helpful
  1. Amit 731 Reputation points
    2022-03-08T04:28:55.74+00:00

    Working with HttpUtility.UrlPathEncode.
    for e.g.
    HttpUtility.UrlPathEncode(file.ServerRelativeUrl, false);
    As file.ServerRelativeUrl parameter contains special character.