Instead of passing a string, try: new FileStream(fileName, FileMode.Open), Encoding.UTF8)
On Mon, Nov 25, 2019 at 12:10 PM Mark J. Bailey <[email protected]> wrote: > That is a bit odd, but then again, M$ VS. I wonder, though, unless it’s > overloaded (STRING being one of them), it would sort of make sense to me as > I normally thing of a STREAM being one of several source input types. Of > course, VS has never been known to be buggy or lacking in Intellisense! :) > The error sounds like when you have a type that can’t be automatically > casted. I know in C# there is ‘string’ and there is ‘String’, and while > they both more or less represent the same thing, they are distinctly > different object types. Go figure! > > > > *From:* [email protected] <[email protected]> *On > Behalf Of *[email protected] > *Sent:* Monday, November 25, 2019 12:02 PM > *To:* [email protected] > *Subject:* RE: [nlug] [OT] Visual Basic Question > > > > Intellisense says to use a string argument. My guess is that I have run > into a managed-code vs. unmanaged-code issue, and that a literal argument > is being silently cast to the proper managed-code string type, but I > haven’t found any documentation saying how to declare a managed-code string. > > > > *From:* [email protected] <[email protected]> *On > Behalf Of *Mark J. Bailey > *Sent:* Monday, November 25, 2019 11:57 AM > *To:* [email protected] > *Subject:* RE: [nlug] [OT] Visual Basic Question > > > > You probably need to create a new STREAM object first (using the STRING > pathname). I’m not VB oriented, but that would be my initial guess. What > does Intellisense say about the StreamReader’s argument types? > > > > *From:* [email protected] <[email protected]> *On > Behalf Of *[email protected] > *Sent:* Monday, November 25, 2019 11:53 AM > *To:* [email protected] > *Subject:* [nlug] [OT] Visual Basic Question > > > > 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? > > > -- > This message has been scanned for viruses and dangerous content by > *E.F.A. Project* <http://www.efa-project.org>, and is believed to be > clean. > Click here to report this message as spam. > <http://jsefagate.jobsoft.com/cgi-bin/learn-msg.cgi?id=172CF160812.AAB0C&token=96656b46d9b063c455fa1582db136a25> > > -- > -- > 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 > <https://groups.google.com/d/msgid/nlug-talk/002f01d5a3b9%24257ec580%24707c5080%24%40jfeldredge.com?utm_medium=email&utm_source=footer> > . > > -- > -- > 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/016401d5a3b9%24c196a410%2444c3ec30%24%40jobsoft.com > <https://groups.google.com/d/msgid/nlug-talk/016401d5a3b9%24c196a410%2444c3ec30%24%40jobsoft.com?utm_medium=email&utm_source=footer> > . > > -- > -- > 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/004201d5a3ba%247e52d560%247af88020%24%40jfeldredge.com > <https://groups.google.com/d/msgid/nlug-talk/004201d5a3ba%247e52d560%247af88020%24%40jfeldredge.com?utm_medium=email&utm_source=footer> > . > > -- > -- > 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/017d01d5a3bb%2491c200c0%24b5460240%24%40jobsoft.com > <https://groups.google.com/d/msgid/nlug-talk/017d01d5a3bb%2491c200c0%24b5460240%24%40jobsoft.com?utm_medium=email&utm_source=footer> > . > -- __________________ Clayton Davis [email protected] -- -- 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/CADaCfqX4XP4T34-iagWO54CXRM_73n2nb9xDwW6yw%3D%3DT1PpH7g%40mail.gmail.com.
