I need to log a bare protobuf response to a file and deserialize it to an object as well. It is only letting me do one or the other. The code below results in a correctly deserialized object but also a blank text file. How can I work this?
try
{
ProtoBuf.Serializer.Serialize(webRequest.GetRequestStream(), myclass);
}
finally
{
webRequest.GetRequestStream().Close();
}
var webRequest = (HttpWebRequest)WebRequest.Create(EndPoint);
webRequest.Method = "POST";
WebResponse response = webRequest.GetResponse();
var responseStream = response.GetResponseStream();
//deserializing using the response stream
myotherclassinstance = ProtoBuf.Serializer.Deserialize<TidalTV.GoogleProtobuffer.BidResponse>(responseStream);
//trying and failing to copy the response stream to the filestream
using (var fileStream = File.Create(Directory.GetCurrentDirectory() + "\\ProtobufResponse"))
{
responseStream.CopyTo(fileStream);
}