Back to Devexpress

Document.SaveDocument(String, DocumentFormat) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-document-dot-savedocument-x28-system-dot-string-devexpress-dot-xtrarichedit-dot-documentformat-x29.md

latest6.5 KB
Original Source

Document.SaveDocument(String, DocumentFormat) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Saves the document to a file, specifying the document’s format.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
void SaveDocument(
    string fileName,
    DocumentFormat format
)
vb
Sub SaveDocument(
    fileName As String,
    format As DocumentFormat
)

Parameters

NameTypeDescription
fileNameString

A string value specifying the path to a file into which to save the control’s document.

| | format | DocumentFormat |

One of the DocumentFormat enumeration values.

|

Remarks

Note

The SaveDocument method call does not automatically change the Modified property value.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SaveDocument(String, DocumentFormat) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/CustomXmlActions.cs#L37

csharp
document.CustomXmlParts.Add(xmlDoc);
document.SaveDocument("Result.docx", DocumentFormat.OpenXml);
System.Diagnostics.Process.Start("explorer.exe", "/select," + "Result.docx");

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/CustomXmlParts.cs#L42

csharp
document.CustomXmlParts.Add(xmlDoc);
document.SaveDocument("Result.docx", DocumentFormat.OpenXml);
System.Diagnostics.Process.Start("explorer.exe", "/select," + "Result.docx");

winforms-rich-edit-manage-tracked-changes/CS/XtraRichEdit_TrackChanges/Form1.cs#L24

csharp
richEditControl1.TrackedMovesConflict += DocumentProcessor_TrackedMovesConflict;
richEditControl1.Document.SaveDocument("DocumentWithRevisions.docx", DocumentFormat.OpenXml);
SpecifyDisplayOptions();

wpf-richedit-manage-tracked-changes/CS/DXRichEdit_TrackChanges/MainWindow.xaml.cs#L21

csharp
AcceptAndRejectRevisions();
richEditControl1.Document.SaveDocument("DocumentWithRevisions.docx", DocumentFormat.OpenXml);

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/CustomXmlActions.vb#L34

vb
document.CustomXmlParts.Add(xmlDoc)
document.SaveDocument("Result.docx", DocumentFormat.OpenXml)
System.Diagnostics.Process.Start("explorer.exe", "/select," & "Result.docx")

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/CustomXmlParts.vb#L39

vb
document.CustomXmlParts.Add(xmlDoc)
document.SaveDocument("Result.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
System.Diagnostics.Process.Start("explorer.exe", "/select," & "Result.docx")

winforms-rich-edit-manage-tracked-changes/VB/XtraRichEdit_TrackChanges/Form1.vb#L19

vb
AddHandler richEditControl1.TrackedMovesConflict, AddressOf DocumentProcessor_TrackedMovesConflict
richEditControl1.Document.SaveDocument("DocumentWithRevisions.docx", DocumentFormat.OpenXml)
SpecifyDisplayOptions()

word-document-api-examples/VB/CodeExamples/StylesActions.vb#L113

vb
' Save the resulting document and select it in the File Explorer.
document.SaveDocument("LinkedStyleSample.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml)
System.Diagnostics.Process.Start("explorer.exe", "/select," & "LinkedStyleSample.docx")

See Also

How to: Save a Document in the RichEditControl

BeforeExport

IUriProvider

LoadDocument

Document Interface

Document Members

DevExpress.XtraRichEdit.API.Native Namespace