0

I’m trying to download files using sharepoint link(path link) using urlmon.DLL in C#. It’s downloading full file sometimes and sometimes it’s creating corrupted file. Any solutions to resolve this?

I tried in vscode c#, it’s definitely downloading file but it’s not happening for every run

Suzie
  • 1
  • 2
  • 2
    Why are you using `urlmon` at all? It's *not* meant for downloading and definitely not meant to be used in C#. There's no reason to use it at all. `HttpClient.GetStreamAsync` will download any file asynchronously. SharePoint is a web application. There are no "path links", files are accessible through their URLs. When you copy a link to a SharePoint document you're copying that document's URL – Panagiotis Kanavos Jan 10 '23 at 19:48
  • Thanks! But HttpClient is not working for me that’s why I got into this. Using the direct path of a file is something I tried, it’s not working anyway. The file I’m referring to is from teams channel of my org so that’s why httpclient is not working I guess! – Suzie Jan 11 '23 at 07:22
  • HttpClient is working perfectly for every SharePoint developer. That's what's used by the SharePoint client packages, the tutorials and samples. The code you tried may have some problems. That means the code needs fixing, not that HttpClient doesn't work. `urlmon` does *NOT* use some different, magic way of issuing HTTP requests – Panagiotis Kanavos Jan 11 '23 at 08:26
  • `from teams channel` then it's not a SharePoint file *at all*. There are clients libraries for Teams as well. The API used is Microsoft Graph, which is well documented with a *lot* of samples and tutorials. The Teams client on your machine uses that API, not the legacy urlmon that's only meant for 2000-era COM applications – Panagiotis Kanavos Jan 11 '23 at 08:28

0 Answers0