How to get a MemoryStream from a Stream in .NET?

后端 未结 9 1089
天命终不由人
天命终不由人 2020-12-02 16:16

I have the following constructor method which opens a MemoryStream from a file path:

MemoryStream _ms;

public MyClass(string filePath)
{
    by         


        
9条回答
  •  猫巷女王i
    2020-12-02 17:08

    You can simply do:

    var ms = new MemoryStream(File.ReadAllBytes(filePath));
    

    Stream position is 0 and ready to use.

提交回复
热议问题