I need to download a file to a specific location in my Electron program.
I tried implementing this API but failed.
Then I tried implementing the official API, but couldn
To allow a user to download a file in an Electron application, you need to do the following:
Get either the default session or the session of the user from the partition. See Session
Once you have an instance of the session object, you can then listen for events like will-download which is emitted on Session
object when the user clicks on a link to download a file and the file is going to be downloaded.
The will-download event returns the item which is going to be downloaded. This item
contains the necessary events (downloaded, failed, paused etc.) and necessary methods (where to save the file) etc.
Now, regarding the query on How to download a file to C:/folder
?
You have 2 choices regarding that:
If you rather want to set the default download location for all the files, then you can use, setDownloadPath on the session object. Then that will be the default path for that session.