question

HemanthB-9452 avatar image
0 Votes"
HemanthB-9452 asked HemanthB-9452 commented

Downloading Folders as Zip Files c#

I created a code that downloads OneDrive folders as zip folders. When the file's downloaded, I checked it was there but when I opened it, it was a displaying an error message saying, the compressed(zip) folder is invalid. Is the below code correct for downloading folders as zip files?



string myWebUrlFile = "https://1drv.ms/u/s!Ag_oTpUdmpVj0XsrWzdJ4YfbyjUd?e=wER6Se";
// Local path where the file will be saved
string myLocalFilePath = "C:/Users/bnara/Pictures/Download.zip";
using (var client = new WebClient())
{
client.DownloadFile(myWebUrlFile, myLocalFilePath);
}

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered HemanthB-9452 commented

Hi HemanthB-9452,
The problem is your file path.
I suggest you find the file path by following steps:
Go to One Drive on the web and right-click on the file that we want and select Embed. Τhen on the right we see the info window to integrate our file into a page. Inside the iframe is the source of the file. Then we have to replace the word embed with the word download and that's it.

  string myWebUrlFile = "https://onedrive.live.com/download?cid=63959A1D954EE80F&resid=63959A1D954EE80F%2110492&authkey=ABQoKVOGlCY54Gk&em=2";

Best Regards,
Daniel Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
email-notifications.htmlElba-3401



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @HemanthB-9452,
May I know whether your issue has been solved or not in this thread? If not, please share it in here. We can work together to figure it out.
Regarding your new question("Add Alarm - C# Alarm"), I will help as soon as possible in that thread.
Best Regards,
Daniel Zhang

0 Votes 0 ·

Yes it has been solved.

0 Votes 0 ·