TimeZoneInfo::FromSerializedString Method
Deserializes a string to re-create an original serialized TimeZoneInfo object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- source
- Type: System::String
The string representation of the serialized TimeZoneInfo object.
| Exception | Condition |
|---|---|
| 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.
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
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.