0

When I looking for way to communicate with Sharepoint OneDrive, I can't understand cridentials and way to login with c# desktop app. And I found another way. I create WebBrowser component, then

WebBrowser.URI = new URI ("my sharepoint site"). 

and get Authorization page. Write my login and password and after that i can create another webBrowser object and get information about file, methadata, information about directories and forders.

But, I can't find way for download file. I have link of download my file.

https://mysite-my.sharepoint.com/personal/myuser_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl('/personal/myuser_onmicrosoft_com/Documents/Shared with Everyone/testExcel.xlsx')/$value. 

When I paste this link in desktopBrowser (like a Google Chrome), bwowser automaticaly download this file on my PC.

And there is queston: How can I do this with .Net WindowsForms WebBrowser component.

I did "WebBrowser.URI = new URI ("my link for download file")." and event WebBrowser.FileDownload is called. But i can't find, where my file was downloaded. It's really downloaded? Or maybe I need to use another way? Thanks

1
  • i am also stucked in same issue can anybody help please.
    – user33353
    Commented Sep 12, 2014 at 7:39

1 Answer 1

1

I've done this with the DownloadFile (sync or async) method of the WebClient class:

    using (WebClient wc = new WebClient())
    {
        wc.Credentials = new NetworkCredential(userName, password, domain);
        wc.DownloadFile(urlOfFile, localFileName);
    }

You can specify credentials or set WebClient.UseDefaultCredentials = true. If you want to download the file asynchronously, use DownloadFileAsync instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.