The problem that the stream can only be read once

problem description, directly look at the picture

上上测试码

 public void test()
        {
            //string url = "https://ssl.ptlogin2.qq.com/ptqrshow?appid=501004106&e=0&l=M&s=5&d=72&v=4&t=#{t}";
            //url = url.Replace("#{t}", rand.NextDouble().ToString());
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://ssl.ptlogin2.qq.com/ptqrshow?appid=501004106&e=0&l=M&s=5&d=72&v=4&t=#{t}".Replace("#{t}", rand.NextDouble().ToString()));
            //HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);     
            //req.Method = "get";
            req.CookieContainer = BLL.SmartQQ.Tool.Http.cookies;
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            BLL.SmartQQ.Tool.Http.cookies.Add(res.Cookies);
            Stream responseStream = res.GetResponseStream();
            //int contentLength = (int)res.ContentLength;
            //int offset = 0;
            //byte[] buffer = new byte[contentLength];
            //while (contentLength > 0)
            //{
            //    int num3 = responseStream.Read(buffer, offset, contentLength);
            //    if (num3 == 0)
            //    {
            //        break;
            //    }
            //    contentLength -= num3;
            //    offset += num3;
            //}
            //pictureBoxQRCode.Image = Image.FromStream(new MemoryStream(buffer));
            pictureBoxQRCode.Image = Image.FromStream(res.GetResponseStream());
            //pictureBoxQRCode.Image = Image.FromStream(responseStream);

           
            
        }

res.GetResponseStream() Read the stream, do not operate for multiple read streams At the time, the default can only be read once

After reading the stream again using res.GetResponseStream(), the code will explode abnormally.

Latest article

  1. In the node middleware (microservices) architecture, it is better to use a node to deploy multiple projects, or is it better to
  2. When Weixin friends are circled, will Microvision be the opponent of vibrato and fast hands?
  3. Sequence Table Application 1: Shift algorithm for redundant element deletion
  4. Blockchain definition and application examples of blockchain technology
  5. "Eective Java second edition Chinese version" e-book attached download link +30 summary JVM virtual machine technical text layou
  6. Algorithm to improve the graphics output
  7. Linux system installation MySQL (with martial arts cheats: search for string shortcuts in the terminal)
  8. Sql syntax of the operation table (ORACLE)
  9. A super easy to use stock financial data interface package API
  10. "Java Performance Tuning Guide" e-book with download link +30 summary JVM virtual machine technical text layout (collection vers
  11. Numpy probability distribution
  12. [LeetCode] [24] [Swap Nodes in Pairs]
  13. Whether List List Map in Java is ordered or not.
  14. Dataset LFW: LFW face database introduction, installation, use of the detailed strategy
  15. R language data read and store
  16. "Java Concurrent Programming Art" e-book with download link +30 summary JVM virtual machine technical text layout (collection ve
  17. Alibaba Cloud vouchers are available for free!
  18. POJ3281 Dining Maximum Flow Entry Dinic Algorithm
  19. "JAVA concurrent programming practice Chinese full version" e-book attached download link +30 summary JVM virtual machine techni
  20. String intern() method learning summary