{"id":185,"date":"2016-09-14T12:46:40","date_gmt":"2016-09-14T12:46:40","guid":{"rendered":"http:\/\/vladymix.es\/?p=185"},"modified":"2016-09-14T12:46:40","modified_gmt":"2016-09-14T12:46:40","slug":"net-framework-streams-to-windows-runtime-streams","status":"publish","type":"post","link":"https:\/\/vladymix.es\/wordpress\/index.php\/2016\/09\/14\/net-framework-streams-to-windows-runtime-streams\/","title":{"rendered":".NET Framework Streams to Windows Runtime Streams"},"content":{"rendered":"<p>Este problema me surgi\u00f3 cuando estaba utilizando un Stream de \u00a0HttpCliente (Windows Runtime Streams) he intentado hacer un\u00a0.AsRandomAccessStream()<\/p>\n<p>Pero no es compatible con operaciones para\u00a0.NET memory stream<\/p>\n<p>Aqu\u00ed el c\u00f3digo.<\/p>\n<pre class=\"lang:c# decode:true\"> public async Task&lt;IRandomAccessStream&gt; ToRuntimeRandomAccessStream(Uri uriLocation)\r\n        {           \r\n            var stream = await this.GetStreamFromUrl(uriLocation);\r\n\r\n            \/\/ Create a .NET memory stream.\r\n            var memStream = new MemoryStream();\r\n\r\n            \/\/ Convert the stream to the memory stream, because a memory stream supports seeking.\r\n            await stream.CopyToAsync(memStream);\r\n\r\n            \/\/ Set the start position.\r\n            memStream.Position = 0;\r\n\r\n            return memStream.AsRandomAccessStream();\r\n       }<\/pre>\n<p>La soluci\u00f3n la encontr\u00e9 en MSDN.<\/p>\n<p>https:\/\/msdn.microsoft.com\/en-us\/library\/dn531021(v=vs.110).aspx<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Este problema me surgi\u00f3 cuando estaba utilizando un Stream de \u00a0HttpCliente (Windows Runtime Streams) he intentado hacer un\u00a0.AsRandomAccessStream() Pero no&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","hentry","category-c","category-windows-store-and-phone"],"_links":{"self":[{"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":1,"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":186,"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/185\/revisions\/186"}],"wp:attachment":[{"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vladymix.es\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}