DownloadFile Method
Downloads the specified file.
Syntax
public void downloadFile();
Remarks
This method downloads the specified file. Set ResourcePath to the absolute path of the file to download before calling this method. The file will be downloaded to the stream specified (if any) by SetDownloadStream. If a stream is not specified and LocalFile is set the file will be saved to the specified location. If a stream is not specified and LocalFile is not set the file data will be held by ResourceData.
To decrypt an encrypted file set EncryptionAlgorithm and EncryptionPassword before calling this method.
dropbox.ResourcePath = "/My Folder/photos.zip" dropbox.LocalFile = "../MyFile.zip"; dropbox.DownloadFile();
Resuming Downloads
The component also supports resuming failed downloads by using the StartByte property. If the download was interrupted, set StartByte to the appropriate offset before calling this method to resume the download.
dropbox.ResourcePath = myRemoteFile; dropbox.LocalFile = downloadFile; dropbox.DownloadFile(); //The transfer is interrupted and DownloadFile() above fails. Later, resume the download: //Get the size of the partially download file dropbox.StartByte = new FileInfo(downloadFile).Length; dropbox.ResourcePath = myRemoteFile; dropbox.LocalFile = downloadFile; dropbox.DownloadFile();
Resuming Encrypted File Downloads
Resuming encrypted file downloads is only supported when LocalFile was set in the initial download attempt. When beginning an encrypted download if LocalFile is set the component will create a temporary file in TempPath to hold the encrypted data until it is complete.
If the download is interrupted DownloadTempFile will be populated with the temporary file holding the partial data.
When resuming, DownloadTempFile must be populated along with StartByte to allow the remainder of the encrypted data
to be downloaded. Once the encrypted data is downloaded it will be decrypted and written to LocalFile.
dropbox.ResourcePath = myRemoteFile; dropbox.LocalFile = downloadFile; dropbox.EncryptionPassword = "password"; dropbox.DownloadFile(); //The transfer is interrupted and DownloadFile() above fails. Later, resume the download: //Get the size of the partially download temp file dropbox.StartByte = new FileInfo(dropbox.Config("DownloadTempFile")).Length; dropbox.ResourcePath = myRemoteFile; dropbox.LocalFile = downloadFile; dropbox.EncryptionPassword = "password"; dropbox.DownloadFile();