Vnext Argument 1: cannot convert from 'string' to 'System.IO.Stream'

后端 未结 1 688
感情败类
感情败类 2021-01-02 15:50

I am trying to create a generic serializer withing a Vnext project and when I call the constructor for StreamWriter it throws this compiler error

相关标签:
1条回答
  • 2021-01-02 16:30

    Here is the Answer from davidfowl

    Thats because it's not available on CoreCLR. Use new StringWriter(File.OpenWrite(path)) instead

    For future reference where can I check if a function is available or not?

    File issues on the https://github.com/dotnet/corefx repository. They will be able to clarify why things are missing in the new framework. I believe the reason this particular overload was removed was because of layering issues between the new packages.

    The assembly that contains StreamWriter shouldn't be directly referencing FileStream:

    new StreamReader(path)
    

    actually does

    new StreamReader(new FileStream(path, options)).
    
    0 讨论(0)
提交回复
热议问题