I have the following CSOM code to check if a folder exists:-

 private static void NewTryToAttachFiles(ClientContext ctx, Web web, List fromList, ListItem fromItem, List toList, ListItem toItem)

     string src = string.Format("{0}/lists/{1}/Attachments/{2}", web.Url, "Lease Agreements", fromItem.Id);      
     if (web.GetFolderByServerRelativeUrl(src).Exists)//this will raise the error

     //code goes here
 NewTryToAttachFiles(context,context.Web, oList2,item,oList,listItem2);

but i am getting this error:-

The property or field 'Exists' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

so how i can load the Exists property? Thanks

1 Answer 1


Basically it gets a Folder without actually loading the values for the folders properties.

Load the (needed) folder properties first before using them.

var folder = web.GetFolderByServerRelativeUrl(src)
context.Load(folder,  f=>f.Exists);

if (folder.Exists)
     //code goes here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.