public static void DebugCommandResponse(NetResponse response, ref BinaryReader reader) { return; string commandName = response.GetType().Name; Regex regex = new Regex("Response"); commandName = regex.Split(commandName)[0]; FileInfo info = new FileInfo(Application.streamingAssetsPath + "/command/" + commandName + ".txt"); if (info.Exists) { info.Delete(); } FileStream fs = info.Create(); fs.Position = 0; fs.SetLength(0); MemoryStream s = new MemoryStream(); int BUFFER_SIZE = 1024; byte[] buf = new byte[BUFFER_SIZE]; int n = reader.Read(buf, 0, BUFFER_SIZE); while (n > 0) { s.Write(buf, 0, n); fs.Write(buf, 0, n); n = reader.Read(buf, 0, BUFFER_SIZE); } s.Position = 0; reader = new BinaryReader(s); fs.Close(); fs.Dispose(); }