SessionStateItemCollection.Serialize(BinaryWriter) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將集合的內容寫入 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)
參數
- writer
- BinaryWriter
BinaryWriter,用於將序列化集合寫入資料流或編碼字串。
範例
下列程式代碼範例會建立並填 SessionStateItemCollection 入集合,並使用 Serialize 方法將內容寫入檔案。
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()
備註
方法 Serialize 可用來將集合的內容 SessionStateItemCollection 寫入會話存放區。
若要從會話存放區擷取串行化 SessionStateItemCollection 物件,請使用 Deserialize 方法。