ReadTimeout threw an exception when converting byte array to Stream

前端 未结 4 669
独厮守ぢ
独厮守ぢ 2021-01-20 06:33

I got this error

ReadTimeout = \'((System.IO.Stream)(ms)).ReadTimeout\' threw an exception of type \'System.InvalidOperationException\'.

M

4条回答
  •  [愿得一人]
    2021-01-20 07:12

    I used the following code and I needed the MemoryStream to be used as email attachment:

    string filename=@"C:\images\myimage.img"
    MemoryStream result = new MemoryStream();
    MemoryStream source = new MemoryStream(File.ReadAllBytes(filename));
    source.WriteTo(result);
    

提交回复
热议问题