/// <summary> /// Downloads the file to disk. /// </summary> /// <param name="objectFile">The file to download.</param> /// <param name="vault">The vault to download from.</param> /// <param name="downloadTo">The location on disk to download to.</param> /// <param name="blockSize">The size of blocks to use to transfer the file from the M-Files vault to this machine.</param> /// <param name="fileFormat">The format of file to request from server.</param> /// <returns>A <see cref="TemporaryFileDownload"/> representing the completed file download.</returns> public static TemporaryFileDownload Download ( this ObjectFile objectFile, Vault vault, FileInfo downloadTo, int blockSize = FileTransfers.DefaultBlockSize, MFFileFormat fileFormat = MFFileFormat.MFFileFormatNative ) { // Sanity. if (null == objectFile) { throw new ArgumentNullException(nameof(objectFile)); } if (null == vault) { throw new ArgumentNullException(nameof(vault)); } // Download the file. return(TemporaryFileDownload.Download ( objectFile, vault, downloadTo, false, blockSize, fileFormat )); }
/// <summary> /// Creates a <see cref="TemporaryFileDownload"/> and downloads <paramref name="fileToDownload"/> /// from the <paramref name="vault"/> to <paramref name="downloadTo"/>. /// </summary> /// <param name="fileToDownload">The file to download.</param> /// <param name="vault">The vault to download from.</param> /// <param name="downloadTo">The location on disk to download to.</param> /// <param name="overwriteExistingFiles">If false and <paramref name="downloadTo"/> exists then an <see cref="InvalidOperationException"/> is thrown.</param> /// <param name="blockSize">The size of the block to use for file transfers (defaults to <see cref="TemporaryFileDownload.DefaultDownloadBlockSize"/>).</param> /// <param name="fileFormat">The format to request the file in from the server.</param> /// <returns></returns> public static TemporaryFileDownload Download( ObjectFile fileToDownload, Vault vault, FileInfo downloadTo, bool overwriteExistingFiles = true, int blockSize = FileTransfers.DefaultBlockSize, MFFileFormat fileFormat = MFFileFormat.MFFileFormatNative ) { // Create the download object. var download = new TemporaryFileDownload ( fileToDownload, vault, downloadTo ); // Download the file. download.Download(overwriteExistingFiles, blockSize, fileFormat); // Return the download object. return(download); }