Version

SaveDateSettings Method

Saves the contents of the DateSettings, DayOfWeekSettings, and RecurringDateSettings, collections to the specified stream.
Syntax
'Declaration
 
Public Sub SaveDateSettings( _
   ByVal stream As Stream _
) 
public void SaveDateSettings( 
   Stream stream
)

Parameters

stream
The System.IO.Stream to which the data is to be serialized.
Example
The following code sample demonstrates how to use the SaveDateSettings method to serialize the value of the IsWorkDay property, and the contents of the WorkingHours and TimeRangeAppearances collection, for each member of an Owner's DateSettings, DayOfWeekSettings, and RecurringDateSettings collections, and how to use the LoadDateSettings method to complete the round-trip:

Imports System.Collections.Generic
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics

    Private Function SaveOwnerDateSettings(ByVal owner As Owner) As Boolean

        If owner Is Nothing Then Return False

        Try

            Dim fileName As String = String.Empty
            Using fileDialog As SaveFileDialog = New SaveFileDialog()

                '  Show the SaveFileDialog to get the path from the user
                fileDialog.FileName = String.Empty
                fileDialog.Title = owner.Key

                If fileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then fileName = fileDialog.FileName
            End Using

            If fileName.Length = 0 Then Return False

            Using stream As System.IO.FileStream = New FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)
                owner.SaveDateSettings(stream)
                stream.Close()
            End Using

            Return True

        Catch
            Return False
        End Try

    End Function

    Private Function LoadOwnerDateSettings(ByVal owner As Owner) As Boolean
        If owner Is Nothing Then Return False

        Try

            Dim fileName As String = String.Empty

            Using fileDialog As OpenFileDialog = New OpenFileDialog()

                fileDialog.Title = owner.Key
                If (fileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then fileName = fileDialog.FileName
            End Using

            If fileName.Length = 0 Then Return False

            Using stream As FileStream = New FileStream(fileName, FileMode.Open, FileAccess.Read)
                owner.LoadDateSettings(stream)
            End Using

            Return True

        Catch
            Return False
        End Try

    End Function
using System.Collections.Generic;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using System.Diagnostics;

    private bool SaveOwnerDateSettings( Owner owner )
    {
        if ( owner == null )
            return false;
        try
        {
            string fileName = string.Empty;
            using ( SaveFileDialog fileDialog = new SaveFileDialog() )
            {
                //  Show the SaveFileDialog to get the path from the user
                fileDialog.FileName = string.Empty;
                fileDialog.Title = owner.Key;

                if ( fileDialog.ShowDialog(this) == DialogResult.OK )
                    fileName = fileDialog.FileName;
            }

            if ( fileName.Length == 0 )
                return false;

            using ( FileStream stream = new System.IO.FileStream(fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite) )
            {
                owner.SaveDateSettings( stream );
                stream.Close();
            }

            return true;
        }
        catch
        {
            return false;
        }
    }

    private bool LoadOwnerDateSettings( Owner owner )
    {
        if ( owner == null )
            return false;

        try
        {
            string fileName = string.Empty;
            using ( OpenFileDialog fileDialog = new OpenFileDialog() )
            {
                fileDialog.Title = owner.Key;
                if ( fileDialog.ShowDialog(this) == DialogResult.OK )
                    fileName = fileDialog.FileName;
            }

            if ( fileName.Length == 0 )
                return false;

            using ( FileStream stream = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read) )
            {
                owner.LoadDateSettings( stream );
            }

            return true;
        }
        catch
        {
            return false;
        }
    }
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