/// <summary> /// Adds a file to the cabinet. /// </summary> /// <param name="file">The file to add.</param> /// <param name="token">The token for the file.</param> public void AddFile(string file, string token) { try { CabInterop.CreateCabAddFile(file, token, this.handle); } catch (DirectoryNotFoundException) { throw new FileNotFoundException("The system cannot find the file specified.", file); } catch (FileNotFoundException) { throw new FileNotFoundException("The system cannot find the file specified.", file); } }
/// <summary> /// Adds an array of files to the cabinet. /// </summary> /// <param name="filePaths">Path to files to add to cabinet.</param> /// <param name="fileIds">Identifiers for all files to add to cabinet.</param> /// <param name="batchAdd">Flag to add the files one at a time or in a batch.</param> public void AddFiles(string[] filePaths, string[] fileIds, bool batchAdd) { if (batchAdd) { this.AddFiles(filePaths, fileIds); return; } for (int i = 0; i < filePaths.Length; i++) { int error = CabInterop.CreateCabAddFile(filePaths[i], fileIds[i], this.handle); if (0 != error) { throw new WixCabCreationException(filePaths[i], error); } } }