Back to Devexpress

XtraSaveFileDialog.OpenFile() Method

windowsforms-devexpress-dot-xtraeditors-dot-xtrasavefiledialog-f6bc3d50.md

latest2.4 KB
Original Source

XtraSaveFileDialog.OpenFile() Method

Opens the user-selected file. The file is opened with read/write permissions.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraDialogs.v25.2.dll

NuGet Packages : DevExpress.Win.Dialogs, DevExpress.Win.Navigation

Declaration

csharp
public Stream OpenFile()
vb
Public Function OpenFile As Stream

Returns

TypeDescription
Stream

A Stream that stores the selected read/write file.

|

Remarks

See the SaveFileDialog.OpenFile article to learn more.

Example

The following example demonstrates how to show the XtraSaveFileDialog.

csharp
using System.IO;

private void simpleButtonSaveFileDialog_Click(object sender, EventArgs e) {
    Stream memoStream;
    xtraSaveFileDialog1.Filter = "txt files (*.txt)|*.txt";

    if(xtraSaveFileDialog1.ShowDialog() == DialogResult.OK) {
        if((memoStream = xtraSaveFileDialog1.OpenFile()) != null) {
            // Code to write the stream goes here.

            memoStream.Close();
        }
    }
}
vb
Imports System.IO

Private Sub simpleButtonSaveFileDialog_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim memoStream As Stream
    xtraSaveFileDialog1.Filter = "txt files (*.txt)|*.txt"

    If xtraSaveFileDialog1.ShowDialog() = DialogResult.OK Then
        memoStream = xtraSaveFileDialog1.OpenFile()
        If memoStream IsNot Nothing Then
            ' Code to write the stream goes here.

            memoStream.Close()
        End If
    End If
End Sub

See Also

XtraSaveFileDialog Class

XtraSaveFileDialog Members

DevExpress.XtraEditors Namespace