Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IAppxPackageWriter::AddPayloadFile method

Adds a new payload file to the app package.

Syntax


HRESULT AddPayloadFile(
  [in] LPCWSTR                 fileName,
  [in] LPCWSTR                 contentType,
  [in] APPX_COMPRESSION_OPTION compressionOption,
  [in] IStream                 *inputStream
);

Parameters

fileName [in]

Type: LPCWSTR

The name of the payload file. The file name path must be relative to the root of the package.

contentType [in]

Type: LPCWSTR

The string specifying the content type of fileName.

compressionOption [in]

Type: APPX_COMPRESSION_OPTION

The type of compression to use to store fileName in the package.

inputStream [in]

Type: IStream*

An IStream providing the contents of fileName. The stream must support Read, Seek, and Stat.

Return value

Type: HRESULT

If the method succeeds, it returns S_OK. Otherwise, it returns an error code that includes, but is not limited to, those in the following table. Error OPC codes, in addition to OPC_E_DUPLICATE_PART may result. If the method fails, the package writer will close in a failed state and can't be used any more.

Return codeDescription
E_INVALIDARG

The compression option specified by compressionOption is not one of the values of the APPX_COMPRESSION_OPTION enumeration.

E_NOT_VALID_STATE

The writer is closed.

HRESULT_FROM_WIN32(ERROR_INVALID_NAME)

The file name specified is not a valid file name or is a reserved name for a footprint file.

OPC_E_DUPLICATE_PART

The file name specified is already in use in the package.

 

Remarks

When the AddPayloadFile method succeeds the contents of the specified fileName are written to the package and a corresponding entry is made in the package block map.

Note  Files with the following reserved filenames cannnot be added to the package using the AddPayloadFile method: \AppxManifest.xml, \AppxBlockMap.xml, \AppxStreamMap.xml , and \AppxSignature.p7x . Also, files with the following reserved folder prefixes cannnot be added to the package using the AddPayloadFile method: \AppxMetadata\ and \Microsoft.System.Package.Metadata\.
 

Examples

For an example, see How to create an app package.

Requirements

Minimum supported client

Windows 8 [desktop apps only]

Minimum supported server

Windows Server 2012 [desktop apps only]

Header

AppxPackaging.h

IDL

AppxPackaging.idl

IID

IID_IAppxPackageWriter is defined as 9099e33b-246f-41e4-881a-008eb613f858

See also

IAppxPackageWriter
APPX_COMPRESSION_OPTION

 

 

Show:
© 2017 Microsoft