lte__
lte__

Reputation: 7586

StreamReader doesn't take string?

I'm trying to read a file with a StreamReader, but I get an error for using path

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

even though it's clear from the documentation, that you should be able to use a string.
What am I missing here?

public MyClass Load(String path)
{
    try
    {
        // exception in this line, `path` is underlined with red
        using (StreamReader reader = new StreamReader(path)) 
        {
            String line = reader.ReadLine();
// ... etc

Upvotes: 1

Views: 1611

Answers (1)

Chuck
Chuck

Reputation: 51

I can't tell if you got your answer or not but the proper syntax for UWP is below:

using (var sr = new StreamReader(new FileStream(filenamestring, FileMode.Open)))

Upvotes: 5

Related Questions