This documentation is archived and is not being maintained.

IVsTrackProjectDocumentsEvents2.OnQueryAddFiles Method

This method notifies the client when a project has requested to add files.

Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop (in

int OnQueryAddFiles (
	[InAttribute] IVsProject pProject,
	[InAttribute] int cFiles,
	[InAttribute] string[] rgpszMkDocuments,
	[InAttribute] VSQUERYADDFILEFLAGS[] rgFlags,
	[OutAttribute] VSQUERYADDFILERESULTS[] pSummaryResult,
	[OutAttribute] VSQUERYADDFILERESULTS[] rgResults
int OnQueryAddFiles (
	/** @attribute InAttribute() */ IVsProject pProject, 
	/** @attribute InAttribute() */ int cFiles, 
	/** @attribute InAttribute() */ String[] rgpszMkDocuments, 
	/** @attribute InAttribute() */ VSQUERYADDFILEFLAGS[] rgFlags, 
	/** @attribute OutAttribute() */ VSQUERYADDFILERESULTS[] pSummaryResult, 
	/** @attribute OutAttribute() */ VSQUERYADDFILERESULTS[] rgResults
function OnQueryAddFiles (
	pProject : IVsProject, 
	cFiles : int, 
	rgpszMkDocuments : String[], 
) : int



[in] Project requesting to add files.


[in] Number of files to add.


[in] Array of files to add to the project.


[in] Array of flags associated with each file. For a list of rgFlags values, see VSQUERYADDFILEFLAGS.


[out] Summary result object. This object is a summation of the yes and no results for the array of files passed in rgpszMkDocuments. If the result for a single file in the array is no, then pSummaryResult is equal to VSQUERYADDFILERESULTS_AddNotOK; if the results for all files are yes, then pSummaryResult is equal to VSQUERYADDFILERESULTS_AddOK. For a list of pSummaryResult values, see VSQUERYADDFILERESULTS.


[out] Array of results for each individual file. For a list of rgResults values, see VSQUERYADDFILERESULTS.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

COM Signature

From IVsTrackProjectDocumentsEvents2.idl

HRESULT IVsTrackProjectDocumentsEvents2::OnQueryAddFiles(
   [in] IVsProject *pProject,
   [in] int cFiles,
   [in, size_is(cFiles)] const LPCOLESTR rgpszMkDocuments[],
   [in, size_is(cFiles)] const VSQUERYADDFILEFLAGS rgFlags[],
   [out] VSQUERYADDFILERESULTS *pSummaryResult,
   [out, size_is(cFiles)] VSQUERYADDFILERESULTS rgResults[]

Use IVsTrackProjectDocumentEvents2.OnQueryAddFiles to indicate whether specified files can be added to the project. Only deny a query if allowing the operation would compromise your stable state. For example, source control denies add queries if a file being added conflicts with an existing file already under source control.