C# – Copying with webclient to sharepoint document library question

csharepointwebdav

When I copy to a sharepoint document library using webclient, should the URL contain the destination filename or not?

For example:

client.UploadFile("http://site/projects/project/documentLibrary/subfolder/" , "PUT", attachmentFileName );

or

client.UploadFile("http://site/projects/project/documentLibrary/subfolder/" + attachmentFileName , "PUT", attachmentFileName );

Can't figure out which one works – because right now neither work for me

Best Answer

The URL MUST include the destination path.

The issue I was facing was easy to overlook, I was including the full file path in the URL, not just the file name.