IFileOperation::NewItem method

Declares a new item that is to be created in a specified location.

Syntax


HRESULT NewItem(
  [in]          IShellItem *psiDestinationFolder,
  [in]          DWORD dwFileAttributes,
  [in, unique]  LPCWSTR pszName,
  [in, unique]  LPCWSTR pszTemplateName,
  [in]          IFileOperationProgressSink *pfopsItem
);

Parameters

psiDestinationFolder [in]

Type: IShellItem*

Pointer to an IShellItem that specifies the destination folder that will contain the new item.

dwFileAttributes [in]

Type: DWORD

A bitwise value that specifies the file system attributes for the file or folder. See GetFileAttributes for possible values.

pszName [in]

Type: LPCWSTR

Pointer to the file name of the new item, for instance Newfile.txt. This is a null-terminated, Unicode string.

pszTemplateName [in]

Type: LPCWSTR

Pointer to the name of the template file (for example Excel9.xls) that the new item is based on, stored in one of the following locations:

  • CSIDL_COMMON_TEMPLATES. The default path for this folder is %ALLUSERSPROFILE%\Templates.
  • CSIDL_TEMPLATES. The default path for this folder is %USERPROFILE%\Templates.
  • %SystemRoot%\shellnew

This is a null-terminated, Unicode string used to specify an existing file of the same type as the new file, containing the minimal content that an application wants to include in any new file.

This parameter is normally NULL to specify a new, blank file.

pfopsItem [in]

Type: IFileOperationProgressSink*

Pointer to an IFileOperationProgressSink object to be used for status and failure notifications. If you call IFileOperation::Advise for the overall operation, progress status and error notifications for the creation operation are included there, so set this parameter to NULL.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

This method does not create the new item, it merely declares the item to be created. To create a new item, you must make at least the sequence of calls detailed here:

  1. Call IFileOperation::NewItem to declare the specifics of the new file or folder.
  2. Call IFileOperation::PerformOperations to create the new item.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Shobjidl.h

IDL

Shobjidl.idl

See also

IFileOperation
PreNewItem
PostNewItem

 

 

Community Additions

ADD
Show:
© 2014 Microsoft