Partager via


IVsUIShell.SaveDocDataToFile Method

Helper method used by editors that implement the IVsPersistDocData interface.

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

Syntax

'Declaration
Function SaveDocDataToFile ( _
    grfSave As VSSAVEFLAGS, _
    pPersistFile As Object, _
    pszUntitledPath As String, _
    <OutAttribute> ByRef pbstrDocumentNew As String, _
    <OutAttribute> ByRef pfCanceled As Integer _
) As Integer
int SaveDocDataToFile(
    VSSAVEFLAGS grfSave,
    Object pPersistFile,
    string pszUntitledPath,
    out string pbstrDocumentNew,
    out int pfCanceled
)
int SaveDocDataToFile(
    [InAttribute] VSSAVEFLAGS grfSave, 
    [InAttribute] Object^ pPersistFile, 
    [InAttribute] String^ pszUntitledPath, 
    [OutAttribute] String^% pbstrDocumentNew, 
    [OutAttribute] int% pfCanceled
)
abstract SaveDocDataToFile : 
        grfSave:VSSAVEFLAGS * 
        pPersistFile:Object * 
        pszUntitledPath:string * 
        pbstrDocumentNew:string byref * 
        pfCanceled:int byref -> int
function SaveDocDataToFile(
    grfSave : VSSAVEFLAGS, 
    pPersistFile : Object, 
    pszUntitledPath : String, 
    pbstrDocumentNew : String, 
    pfCanceled : int
) : int

Parameters

  • pPersistFile
    Type: Object

    [in] Pointer to the IUnknown interface of the file in which the doc data is to be saved.

  • pszUntitledPath
    Type: String

    [in] File path to which the doc data for an as-yet unsaved document is to be saved.

  • pbstrDocumentNew
    Type: String%

    [out] New document file name.

  • pfCanceled
    Type: Int32%

    [out] Set to true if the user aborts the save by clicking the Cancel button.

Return Value

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

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsUIShell::SaveDocDataToFile(
   [in] VSSAVEFLAGS grfSave,
   [in] IUnknown *pPersistFile,
   [in] LPCOLESTR pszUntitledPath,
   [out] BSTR *pbstrDocumentNew,
   [out] BOOL *pfCanceled
);

This method helps implement the Save As dialog box. The document data object implements IPersistFileFormat to perform the save operation. This method manages the Save As dialog box using the IPersistFileFormat pointer passed as input.

The standard case is when a document saves all of its information to a file. Typically, a save operation fails if there is a problem with the destination (for example, disk full, disk write protected, not correct, and so on). An object is not expected to fail a save operation for other reasons than a bad choice of destination. Thus, if the save failed, the user is informed of the problem and is led to the dialog box where a new destination can be chosen (that is, the Save As dialog box). For the case where a document saves some information to a separate store and other information to the file, if the save of the first information to the separate store fails, there is no point in trying a different destination for the file portion. In this situation the document returns a value of OLE_E_PROMPTSAVECANCELED from Save.

.NET Framework Security

See Also

Reference

IVsUIShell Interface

Microsoft.VisualStudio.Shell.Interop Namespace