示例#1
0
 internal static extern void CreateCabAddFile(string file, string token, MsiInterop.MSIFILEHASHINFO fileHash, IntPtr contextHandle);
示例#2
0
 /// <summary>
 /// Adds a file to the cabinet with an optional MSI file hash.
 /// </summary>
 /// <param name="file">The file to add.</param>
 /// <param name="token">The token for the file.</param>
 /// <param name="fileHash">The MSI file hash of the file.</param>
 private void AddFile(string file, string token, MsiInterop.MSIFILEHASHINFO fileHash)
 {
     try
     {
         NativeMethods.CreateCabAddFile(file, token, fileHash, this.handle);
     }
     catch (COMException ce)
     {
         if (0x80004005 == unchecked((uint)ce.ErrorCode)) // E_FAIL
         {
             throw new WixException(WixErrors.CreateCabAddFileFailed());
         }
         else if (0x80070070 == unchecked((uint)ce.ErrorCode)) // ERROR_DISK_FULL
         {
             throw new WixException(WixErrors.CreateCabInsufficientDiskSpace());
         }
         else
         {
             throw;
         }
     }
     catch (DirectoryNotFoundException)
     {
         throw new WixFileNotFoundException(file);
     }
     catch (FileNotFoundException)
     {
         throw new WixFileNotFoundException(file);
     }
 }