Proto Buffers不以可读格式存储数据

Van*_*s S 1 c# protocol-buffers

我将我的protobuf消息保存到文件,格式全部搞砸了.我已经看到它在protobug消息以与.proto文件几乎相同的格式保存到磁盘之前完成.我这样做:

using (Stream output = File.OpenWrite(@"logs\listings.txt"))
{          
    listingBook.AddClisting(_listing);
    listingBook.Build().WriteTo(output);
}
Run Code Online (Sandbox Code Playgroud)

但我得到的是一个错误的文件,似乎ENTER与奇怪的标签分开.将它保存到磁盘时我想要的样子就像示例:

# Textual representation of a protocol buffer.
# This is *not* the binary format used on the wire.
person {
  name: "John Doe"
  email: "jdoe@example.com"
}
Run Code Online (Sandbox Code Playgroud)

Ben*_*igt 6

更加注意评论

不是电线上使用的二进制格式.

Protobuf消息的设计不是人类可读的.将它们存储在文本文件中毫无意义; 它们不是文字.