Export (0) Print
Expand All

TimeZoneInfo.FromSerializedString Method

Deserializes a string to re-create an original serialized TimeZoneInfo object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

static member FromSerializedString : 
        source:string -> TimeZoneInfo

Parameters

source
Type: System.String

The string representation of the serialized TimeZoneInfo object.

Return Value

Type: System.TimeZoneInfo
The original serialized object.

ExceptionCondition
ArgumentException

The source parameter is String.Empty.

ArgumentNullException

The source parameter is a null string.

SerializationException

The source parameter cannot be deserialized back into a TimeZoneInfo object.

There is an alternative to providing all the code required to create a time zone that is not found in the registry. You can define a custom time zone and either use the ToSerializedString method in a standalone executable or use an application's setup program to save the time zone as a string. The application can then retrieve this string from its storage location and instantiate it using the FromSerializedString method.

The following example tries to retrieve the Antarctica/South Pole time zone from the local system. If it fails, the code tries to retrieve information about the time zone from a text file in the application directory. If this attempt fails, the code creates the time zone and writes information about the time zone to the text file.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft