IBackgroundCopyJob::AddFile method (bits.h)
Adds a single file to the job.
HRESULT AddFile( LPCWSTR RemoteUrl, LPCWSTR LocalName );
Null-terminated string that contains the name of the file on the server. For information on specifying the remote name, see the RemoteName member and Remarks section of the BG_FILE_INFO structure.
Null-terminated string that contains the name of the file on the client. For information on specifying the local name, see the LocalName member and Remarks section of the BG_FILE_INFO structure.
This method returns the following HRESULT values, as well as others.
||File was successfully added to the job.|
||Upload jobs can only contain one file; you cannot add another file to the job.|
||The MaxFilesPerJob Group Policy setting determines how many files a job can contain. Adding the file to the job exceeds the MaxFilesPerJob limit.|
You can receive this error for one of the following reasons:
||User does not have permission to write to the specified directory on the client.|
To add more than one file at a time to a job, call the IBackgroundCopyJob::AddFileSet method. It is more efficient to call the AddFileSet method when adding multiple files to a job than to call the AddFile method in a loop. For more information, see Adding Files to a Job.
To add a file to a job from which BITS downloads ranges of data from the file, call the IBackgroundCopyJob3::AddFileWithRanges method.
Upload jobs can only contain one file. If you add a second file, the method returns BG_E_TOO_MANY_FILES.
For downloads, BITS guarantees that the version of a file (based on file size and date, not content) that it transfers will be consistent; however, it does not guarantee that a set of files will be consistent. For example, if BITS is in the middle of downloading the second of two files in the job at the time that the files are updated on the server, BITS restarts the download of the second file; however, the first file is not downloaded again.
Note that if you own the file being downloaded from the server, you should create a new URL for each new version of the file. If you use the same URL for new versions of the file, some proxy servers may serve stale data from their cache because they do not verify with the original server if the file is stale.
For uploads, BITS generates an error if the local file changes while the file is transferring. The error code is BG_E_FILE_CHANGED and the context is BG_ERROR_CONTEXT_LOCAL_FILE.
BITS transfers the files within a job sequentially. If an error occurs while transferring a file, the job moves to an error state and no more files within the job are processed until the error is resolved.
By default, a user can add up to 200 files to a job. This limit does not apply to administrators or service accounts. To change the default, set the MaxFilesPerJob group policies.
Prior to Windows Vista: There is no limit on the number of files that a user can add to a job.
For scalability concerns, see Best Practices When Using BITS.
For an example that adds a single file to a job, see Adding Files to a Job.
|Minimum supported client||Windows XP|
|Minimum supported server||Windows Server 2003|