restsharp/RestSharp — pull request #354 by akcoder (2013-03-08 18:40:59+00:00)
Title: Add ContentLength to the RestClient.AddFile method which takes in a path

When uploading a file you have the path to, the ContentLength should be known and is safe to set on the FileParameter. I get a System.Net.ProtocolViolationException when trying to upload a file without setting the ContentLength on the FileParameter. The exception message is "Bytes to be written to the stream exceed the Content-Length bytes size specified"

Since the easiest way to accomplish this is to use the FileInfo class, I took the liberty of altering the code in the method which set the FileName to Path.GetFileName(...) to use fileInfo.Name since we will have that information available.

Please let me know if I need to make any changes to get this committed!

-dan