Thursday, November 29, 2018

Check if the folder or file exists in Sharepoint C# CSOM

                                  var url = "/sites/sitecol/DocLib/FolderName;
                                  try
                                {
                                    var file = ctx.Web.GetFileByServerRelativeUrl(url);
                                    ctx.Load(file);
                                    ctx.ExecuteQuery();
                                 }
                                catch (ServerException ex) {

                                       if (ex.ServerErrorTypeName == "System.IO.FileNotFoundException") {
                                                                      }
                                           }

Error: Could not create SSL/TLS Secure channel

Solution include


ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;


We have to make sure that the server and the client have common protocol support.