SessionStateItemCollection.Serialize(BinaryWriter) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Writes the contents of the collection to a BinaryWriter.
public:
void Serialize(System::IO::BinaryWriter ^ writer);
public void Serialize (System.IO.BinaryWriter writer);
member this.Serialize : System.IO.BinaryWriter -> unit
Public Sub Serialize (writer As BinaryWriter)
Parameters
- writer
- BinaryWriter
The BinaryWriter used to write the serialized collection to a stream or encoded string.
Examples
The following code example creates and populates a SessionStateItemCollection collection and writes the contents to a file using the Serialize method.
SessionStateItemCollection items = new SessionStateItemCollection();
items["LastName"] = "Wilson";
items["FirstName"] = "Dan";
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(
System.IO.File.Open(Server.MapPath("session_collection.bin"), System.IO.FileMode.Create));
items.Serialize(writer);
writer.Close();
Dim items As SessionStateItemCollection = New SessionStateItemCollection()
items("LastName") = "Wilson"
items("FirstName") = "Dan"
Dim writer As System.IO.BinaryWriter = New System.IO.BinaryWriter( _
System.IO.File.Open(Server.MapPath("session_collection.bin"), System.IO.FileMode.Create))
items.Serialize(writer)
writer.Close()
Remarks
The Serialize method can be used to write the contents of a SessionStateItemCollection collection to the session store.
To retrieve a serialized SessionStateItemCollection object from the session store, use the Deserialize method.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈