TimeZoneInfo::FromSerializedString Method (String^)
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.
Available since 3.5