Accessing Sharepoint Documents from Winforms via HTTPS

 I was recently asked how someone could access a document in a Sharepoint list from a Winforms client. His only caveat was that it was secured via SSL.

This is the code I gave him, and it seems to work!

System.Net.WebClient Client = new System.Net.WebClient();

Client.UseDefaultCredentials = false ;

System.Net.ICredentials creds;

creds = new System.Net.NetworkCredential(@"MyUserID", "MyPassword");

Client.Credentials = creds;

Client.DownloadFile("https://www.MyDomain.com/someFolder/shared%20documents/DocumentIWant.doc", @"C:\DocumentIWant.doc");