RVTDocs.com
Namespace: Autodesk.Revit.DB Class: Document

Document.Close

Method
Description:
Closes the document, save the changes if there are.
Remarks:
The currently active document may not be closed by this function. It can only be closed via Revit's UI.

The changes will saved automatically, the document will not be closed if failed to save changes. If the document was created in this current session and has not been saved to a file yet, it needs to call Revit::UI::UIDocument::SaveAndClose() method instead.

Syntax
public bool Close()
Exceptions
Exception Condition
InvalidOperationException Thrown when attempting to close the currently active document. Thrown if there are any transactions, sub-transactions or transaction groups which were opened by the API code, and not closed. All of these items must be handled before attempting to close the document. Thrown if the PathName is not set yet. Thrown if the saving target file is read only.
InvalidOperationException Thrown if this a linked file.