Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

How canI pass a path of a file fromUI to filestream?

$
0
0

Hy guys,

My task is to take some string from GUI (which is supposed to be a path to the file) and to read a file from the filestream.

pretty simle, but I failed with the mission.

the code snippet is like this:

        

 public class BI
    {

        string _path;

        FileStream stream = new FileStream(_path, FileMode.Open, FileAccess.Read);
        StreamReader reader = new StreamReader(stream);



        public LottoMashine(string path)
        {
            _path = Path.Combine(path);
        }
    }

What do I get?

Error2 A field initializer cannot reference the non-static field, method, or property 

What did I do the wrong pay?


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>