am trying to do a simple operation "Delete file from document library using CSOM"
As i have only the Relative path http://hostname/subsite/subsite/doclibname/sample.docx
I used below code to get the File object and then delete it.
Microsoft.SharePoint.Client.File file = clientContext.Web.GetFileByServerRelativeUrl(relativePath);
clientContext.Load(file);
file.DeleteObject();
clientContext.ExecuteQuery();
The code executes without errors. However the file doesn't get deleted.
Googled for it. Getting solutions of using LibraryName. However in real scenario i won't be getting the document library name. I will be just getting URL.
Kindly advise.
.Load(file, f => f.Exists);and check the property after execute