序列化对象并将其写入磁盘
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了序列化对象并将其写入磁盘相关的知识,希望对你有一定的参考价值。
Serializes any object and writes it to the specified location on the disk.Example:
Dim obj As DataTable
'save obj to disk
SerializeToFile(filepath, obj)
'to read it back, use DirectCast
Dim obj2 As DataTable = DirectCast(My.Computer.FileSystem.ReadAllBytes(filepath), DataTable)
'serialize an object to a file Public Shared Sub SerializeToFile(ByVal path As String, ByVal data As Object) Try Dim BF As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter() Dim MS As New System.IO.MemoryStream() BF.Serialize(MS, data) My.Computer.FileSystem.WriteAllBytes(path, MS.GetBuffer(), False) Catch ex As Exception Throw ex End Try End Sub
以上是关于序列化对象并将其写入磁盘的主要内容,如果未能解决你的问题,请参考以下文章
从 BigQuery 读取数据并将其写入云存储上的 avro 文件格式