My guess would be that because you're not explicitly providing a class
name for the function, the compiler is "guessing" the wrong class.
So, instead, you might want to tell it explicitly which function you
want, i.e. instead of:

Using reader as StreamReader = new StreamReader(thisFile)

try

Using reader as StreamReader = new My.Computer.FileSystem.StreamReader(thisFile)

On Mon, Nov 25, 2019 at 11:52 AM <[email protected]> wrote:
>
> I am trying to code a Visual Basic 2019 console app that makes use of the 
> StreamReader object to read text from a file. According to the Microsoft 
> documentation for the StreamReader object, when it is initialized, you pass a 
> string with the path of the file to be opened, such as
>
>
>
> Using reader as StreamReader = new StreamReader(“c:\sample.txt”)
>
>
>
> However, all of the Microsoft documentation has the path hard-coded, not as a 
> variable.  In my code, I am declaring a variable as type string, calculating 
> its value at runtime, and passing that string to StreamReader as an argument.
>
>
>
> Dim thisFile as string
>
>
>
> Using reader as StreamReader = new StreamReader(thisFile)
>
>
>
> This results in a compile-time error, BC30311 Value of type ‘String’ cannot 
> be converted to ‘Stream’
>
>
>
> What data type do I need to declare the variable as, instead of as a string, 
> for this to compile and work?
>
> --
> --
> You received this message because you are subscribed to the Google Groups 
> "NLUG" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to 
> [email protected]
> For more options, visit this group at 
> http://groups.google.com/group/nlug-talk?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "NLUG" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/nlug-talk/002f01d5a3b9%24257ec580%24707c5080%24%40jfeldredge.com.



-- 
Tilghman

-- 
-- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nlug-talk?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nlug-talk/CAHPkZcVGaPygNepU4gP0tz4J%3DxwjxzdGd__e9S93SJRMpZqF3g%40mail.gmail.com.

Reply via email to