Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# HttpWebRequest错误在WP8.1上读取超过65536字节_C#_Windows Phone 8_Windows Phone 8.1_Httpwebrequest - Fatal编程技术网

C# HttpWebRequest错误在WP8.1上读取超过65536字节

C# HttpWebRequest错误在WP8.1上读取超过65536字节,c#,windows-phone-8,windows-phone-8.1,httpwebrequest,C#,Windows Phone 8,Windows Phone 8.1,Httpwebrequest,下面的代码从MJPEG视频流中读取字节。 它在Windows8.1商店应用程序上运行良好,但同样的代码在WindowsPhone8.1应用程序上失败 读取65536字节后,方法Read不会从流中读取更多字节 同样的问题 有人告诉我们属性DefaultMaximumErrorResponseLength,但该属性仅在WPF中,不在windows应用商店.net中 WP8.1上的WebClient类也有同样的问题 in说WebClient没有这个问题,但事实并非如此 示例代码: va

下面的代码从MJPEG视频流中读取字节。 它在Windows8.1商店应用程序上运行良好,但同样的代码在WindowsPhone8.1应用程序上失败

读取65536字节后,方法Read不会从流中读取更多字节

同样的问题

有人告诉我们属性DefaultMaximumErrorResponseLength,但该属性仅在WPF中,不在windows应用商店.net中

WP8.1上的WebClient类也有同样的问题

in说WebClient没有这个问题,但事实并非如此

示例代码:

        var request = (HttpWebRequest)WebRequest.CreateHttp("http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?resolution=352x288");
        request.AllowReadStreamBuffering = false;
        request.BeginGetResponse(OnGetResponse, request);


    private void OnGetResponse(IAsyncResult asyncResult)
    {
        HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState;
            HttpWebResponse resp = (HttpWebResponse)req.EndGetResponse(asyncResult);
            Stream s = resp.GetResponseStream();
        byte[] buff = new byte[ChunkSize];
        int readed;
        do
        {
            readed = s.Read(buff, 0, ChunkSize);
        }
        while (readed > 0);
    }

对于大文件,您可以使用BackgroundDownloader类查看此示例是无限流,没有结束。我不能将其存储到文件中,也不希望这样,因为我需要来自流的实时数据。