/// <summary> /// Disposes of the BackgroundCopyJob object. /// </summary> public void Dispose() { try { this.NotifyFlags = 0; m_ijob.SetNotifyInterface(null); } catch { } m_files = null; m_ijob = null; m_ijob2 = null; m_ijob3 = null; m_notifier = null; }
private void ReqJob3() { try { m_ijob3 = (IBackgroundCopyJob3)m_ijob; } catch { throw new NotSupportedException(); } }
/// <summary>Add a file to a download job and specify the ranges of the file you want to download.</summary> /// <param name="remoteFilePath"> /// Contains the name of the file on the server (for example, http://[server]/[path]/file.ext). The format of the name must conform to the transfer /// protocol you use. You cannot use wildcards in the path or file name. The URL must contain only legal URL characters; no escape processing is /// performed. The URL is limited to 2,200 characters, not including the null terminator. You can use SMB to express the remote name of the file to /// download or upload; there is no SMB support for upload-reply jobs. You can specify the remote name as a UNC path, full path with a network drive, or /// use the "file://" prefix. /// </param> /// <param name="localFilePath"> /// Contains the name of the file on the client. The file name must include the full path (for example, d:\myapp\updates\file.ext). You cannot use /// wildcards in the path or file name, and directories in the path must exist. The user must have permission to write to the local directory for /// downloads and the reply portion of an upload-reply job. BITS does not support NTFS streams. Instead of using network drives, which are session /// specific, use UNC paths. /// </param> /// <param name="initialOffset">Zero-based offset to the beginning of the range of bytes to download from a file.</param> /// <param name="length">Number of bytes in the range.</param> public void Add(string remoteFilePath, string localFilePath, long initialOffset, long length = -1) { IBackgroundCopyJob3 ijob3 = null; try { ijob3 = (IBackgroundCopyJob3)m_ijob; } catch { throw new NotSupportedException(); } var rng = new[] { new BG_FILE_RANGE { InitialOffset = (ulong)initialOffset, Length = length == -1 ? ulong.MaxValue : (ulong)length } }; try { ijob3.AddFileWithRanges(remoteFilePath, localFilePath, 1, rng); } catch (COMException cex) { HandleCOMException(cex); } }