Version

SaveAsBinary(String) Method

Saves properties, structure, and data information to a file in binary format.
Syntax
'Declaration
 
Public Overloads Sub SaveAsBinary( _
   ByVal filename As String _
) 
public void SaveAsBinary( 
   string filename
)

Parameters

filename
The name of the file containing the serialized UltraDataSource information
Remarks

The SaveAsBinary method is used in conjunction with the LoadFromBinary(String) method to persist the property settings and layout of the ultraDataSource.

Example
Following code shows how to use Save and Load methods of the UltraDataSource to save data in an UltraDataSource to a file and retrieve it later on. Data can be saved in XML or binary format. To save in XML format, use the SaveAsXml method. If SaveAsXml was used to save data then LoadFromXml must be used to retrieve the data from that file. The same applies to SaveAsBinary and LoadFromBinary methods as well.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinDataSource


    Private Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveButton.Click
        ' Following code saves the data to an XML file for loading at
        ' a later time.

        Dim saveFileDlg As SaveFileDialog = New SaveFileDialog()
        saveFileDlg.Filter = "XML File|*.xml"
        saveFileDlg.OverwritePrompt = True
        Dim dialogResult As DialogResult = saveFileDlg.ShowDialog(Me)

        If dialogResult.OK = dialogResult Then
            ' Pass in true for the includeData parameter to save the data
            ' otherwise it will only save the structure.
            '
            Me.ultraDataSource1.SaveAsXml(saveFileDlg.FileName, True)
        End If
    End Sub

    Private Sub LoadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles loadButton.Click
        ' Following code loads previously saved data from a file.

        Dim openFileDlg As OpenFileDialog = New OpenFileDialog()
        openFileDlg.Filter = "XML File|*.xml"
        Dim dialogResult As DialogResult = openFileDlg.ShowDialog(Me)

        If dialogResult.OK = dialogResult Then
            ' Pass in true for the includeData parameter to load the data
            ' and not just the structure.
            '
            Me.ultraDataSource1.LoadFromXml(openFileDlg.FileName, True)
        End If
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinDataSource;
using System.Diagnostics;


		private void saveButton_Click(object sender, System.EventArgs e)
		{
			// Following code saves the data to an XML file for loading at
			// a later time.

			SaveFileDialog saveFileDlg = new SaveFileDialog( );
			saveFileDlg.Filter = "XML File|*.xml";
			saveFileDlg.OverwritePrompt = true;
			DialogResult dialogResult = saveFileDlg.ShowDialog( this );

			if ( DialogResult.OK == dialogResult )
			{
				// Pass in true for the includeData parameter to save the data
				// otherwise it will only save the structure.
				//
				this.ultraDataSource1.SaveAsXml( saveFileDlg.FileName, true );
			}
		}

		private void loadButton_Click(object sender, System.EventArgs e)
		{
			// Following code loads previously saved data from a file.

			OpenFileDialog openFileDlg = new OpenFileDialog( );
			openFileDlg.Filter = "XML File|*.xml";
			DialogResult dialogResult = openFileDlg.ShowDialog( this );

			if ( DialogResult.OK == dialogResult )
			{
				// Pass in true for the includeData parameter to load the data
				// and not just the structure.
				//
				this.ultraDataSource1.LoadFromXml( openFileDlg.FileName, true );
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also