SharePoint web services: test if file exists

sharepointweb services

I'm using SharePoint web services in C#. I have my code working to check files and check them out using the Lists web service. I need to test to see if a file exists; I can find lots of examples for doing this using the object model API, but I can't seem to find a straightforward way of doing this using web services.

Best Answer

Try the Lists.GetListItems with a suitable CAML query.

A CAML query like

<Query><Where><Eq><FieldRef Name="FileLeafRef" /><Value Type="Text">Filename.rtf</Value></Eq></Where></Query>

should work; the field 'FileLeafRef' is where the filename is stored.