Question: I'm coding in C# using CSOM, my app uploads a template asp.net page to the "/Pages/" library, I need it to check if a file exists in that location with the same name prior to file upload (then maybe it can return a bool value).

I did have a quick look but the majority of the solutions I found referred to the use of Javascript, or applied to on-prem deployments.

If someone could please point me in the right direction I would appreciate it.

Answer: 
An alternative to the Web.GetFileByServerRelativeUrl (@vadim posted above) is `Load(checkFile, p => p.Exists);` and in context ...

```
using (ClientContext ctx = new ClientContext("https://yoursubdomainhere.sharepoint.com/"))
{
    Web web = ctx.Web;
    Microsoft.SharePoint.Client.File checkFile = web.GetFileByServerRelativeUrl("/sites/Documents/MyFile.docx");

    ctx.Load(checkFile, fe => fe.Exists);
    ctx.ExecuteQuery();
    if (!checkFile.Exists)
    {
        //Do something here
    }
}

```
Using Linq To SharePoint

```
    public bool FolderExists(string library, string name) {

        using (var ctx = SPStatic.Context(_sharePointSiteUrl)) {

            List sharedDocs = ctx.Web.Lists.GetByTitle(library);

            var query = ctx.LoadQuery(sharedDocs.RootFolder.Folders.Where(fd => fd.Name == name));

            ctx.ExecuteQuery();

            Folder f = query.SingleOrDefault();

            return f != null;

        }

    }

```