Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

c# reading from text file

$
0
0

Receive two error

1. The type or namespace name 'async' could not be found (are you missing a using directive or an assembly reference?

2.The name 'await' does not exist in the current context

public async void Main()

    {
         try
            {
                using (StreamReader sr = new StreamReader("c:\\TestFile.txt"))
                {
                    String line = await sr.ReadToEndAsync();
                    ResultBlock.Text = line;
                }
            }
            catch (Exception ex)
            {
                ResultBlock.Text = "Could not read the file";
            }


    }


Support@Mytechnet.me


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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