Compartir a través de


IVsQueryEditQuerySave2.QuerySaveFiles Method

Notifies the environment that multiple files are about to be saved.

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

Syntax

'Declaration
Function QuerySaveFiles ( _
    rgfQuerySave As UInteger, _
    cFiles As Integer, _
    rgpszMkDocuments As String(), _
    rgrgf As UInteger(), _
    rgFileInfo As VSQEQS_FILE_ATTRIBUTE_DATA(), _
    <OutAttribute> ByRef pdwQSResult As UInteger _
) As Integer
int QuerySaveFiles(
    uint rgfQuerySave,
    int cFiles,
    string[] rgpszMkDocuments,
    uint[] rgrgf,
    VSQEQS_FILE_ATTRIBUTE_DATA[] rgFileInfo,
    out uint pdwQSResult
)
int QuerySaveFiles(
    [InAttribute] unsigned int rgfQuerySave, 
    [InAttribute] int cFiles, 
    [InAttribute] array<String^>^ rgpszMkDocuments, 
    [InAttribute] array<unsigned int>^ rgrgf, 
    [InAttribute] array<VSQEQS_FILE_ATTRIBUTE_DATA>^ rgFileInfo, 
    [OutAttribute] unsigned int% pdwQSResult
)
abstract QuerySaveFiles : 
        rgfQuerySave:uint32 * 
        cFiles:int * 
        rgpszMkDocuments:string[] * 
        rgrgf:uint32[] * 
        rgFileInfo:VSQEQS_FILE_ATTRIBUTE_DATA[] * 
        pdwQSResult:uint32 byref -> int
function QuerySaveFiles(
    rgfQuerySave : uint, 
    cFiles : int, 
    rgpszMkDocuments : String[], 
    rgrgf : uint[], 
    rgFileInfo : VSQEQS_FILE_ATTRIBUTE_DATA[], 
    pdwQSResult : uint
) : int

Parameters

  • rgfQuerySave
    Type: UInt32

    [in] Flags are currently unused. The caller should always pass in the default null flag, which is zero.

  • cFiles
    Type: Int32

    [in] File count.

  • rgpszMkDocuments
    Type: array<String[]

    [in] Path to the file on the disk.

  • rgrgf
    Type: array<UInt32[]

    [in] Flags whose values are taken from the tagVSQEQSFlags enumeration for valid file attributes. Default = 0.

  • pdwQSResult
    Type: UInt32%

    [out] Pointer to a value taken from the tagVSQuerySaveResult enumeration.

Return Value

Type: Int32

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

  • QSR_SaveOK

  • Save the file. The file should not be read-only at this point.

  • QSR_ForceSaveAs

  • This method has not put up a Save As dialog box, but either it is quietly telling you to do so, or the user has been prompted and has selected Save As. If you are editing a conventional file, you are encouraged to call GetSaveFileNameViaDlg at this point.

    QSR_NoSave_UserCanceled

    The user was notified that the file is read-only and has elected either to not save or to cancel the operation. The choice depends on the BeginQuerySaveBatch / EndQuerySaveBatch methods .

Note

If the editor is trying to save multiple files, you must know the batching state and the difference between no and cancel. Call the QuerySaveFile method for each individual file. If the environment returns QSR_NoSave_UserCanceled or QSR_NoSave_Cancel, then the save is canceled. If the environment returns QSR_NoSave_Continue, then that one file in the batch will not be saved, but you can continue to save the other files.

The results for *pdwQSResult are:

Remarks

COM Signature

From ivsqueryeditquerysave2.idl

HRESULT QuerySaveFiles(
   [in] VSQuerySaveFlags rgfQuerySave,
   [in] int cFiles,
   [in, size_is(cFiles)] const LPCOLESTR rgpszMkDocuments[],
   [in, size_is(cFiles)] const VSQEQSFlags rgrgf[],
   [in, size_is(cFiles)] const VSQEQS_FILE_ATTRIBUTE_DATA rgFileInfo[],
   [out, retval] VSQuerySaveResult *pdwQSResult
);

Before a project or editor saves a file, it must call this method or the QuerySaveFile method. For project files, these calls are automatically completed by the solution, which knows when to save a project file. Editors are responsible for making these calls unless the editor implementation of IVsPersistDocData2 uses the helper function SaveDocDataToFile method. If your editor implements IVsPersistDocData2 in this way, then the call to QuerySaveFile method or QuerySaveFiles is made for you.

Call this method before saving anything to disk. It will handle read-only and checked-in files in a uniform, shared way.

This method might need to issue a checkout command to ensure that the file is writable (for example, if the file was edited in memory). For a source control provider that provides for the "checkout local version" option, this is a safe operation. For a source control provider that does not, the checkout operation cannot be completed without data loss. In this case, Save As is the only option.

.NET Framework Security

See Also

Reference

IVsQueryEditQuerySave2 Interface

Microsoft.VisualStudio.Shell.Interop Namespace