gpt4 book ai didi

vb.net - 如何将字典(集合)对象写入文件(VB .Net 2010)

转载 作者:行者123 更新时间:2023-12-02 15:39:27 24 4
gpt4 key购买 nike

我正在尝试将词典集合写入文件。

集合的结构如下:

GlobalCollection    (Collection of TestCollection)
(0)
[KEY]
[Value]
- TotalGlobal_W_Count (Integer)
- TotalGlobal_I_Count (Integer)
- TotalGlobal_F_Count (Integer)
TestCollection (Dictionary - Key, Value)
(0)
[KEY]
[Value]
- NumberOfTests (Integer)
- TestCollectionName (String)
- TypesOfTests (ArrayList)
ResultsCollection (Dictionary - Key, Value)
(0)
[KEY]
[Value]
- TotalFcount (Integer)
- TotalIcount (Integer)
- TotalWcount (Integer)
- ID (String)
- TestFolderType(String)
- TestPassed (Boolean)
- FullLog (Array)
ResultsCollection (Dictionary - Key, Value)
(0)
[KEY]
[Value]
- LineNumber (Integer)
- MessageType (String)
- ResultString (String)

我想将上述所有变量写到一个文本文件中,同时保持层次结构格式。 (注意每个集合对象中可以有多个元素)

谢谢!!!

最佳答案

比 xml 更快更小,如果您不打算解析/...序列化文件,则使用 BinaryFormater:

Dim MyFormatter As New BinaryFormatter()
Dim MyFile As New FileStream("Serialized.ser", FileMode.Create, FileAccess.Write, FileShare.None)
MyFormatter.Serialize(MyFile, TheObjectIWantToSerialize)
MyFile.Close()

关于vb.net - 如何将字典(集合)对象写入文件(VB .Net 2010),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10457414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com