Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Streams and Data Processing Reading Data Console I/O

Calvin Secrest
Calvin Secrest
24,815 Points

Inside the using block, write the contents of the first line of the file to the Console.

Inside the using block, write the contents of the first line of the file to the Console.

The command won't compile is there a missing char? I'm confused on the syntax with this challenge.

CodeChallenge.cs
DirectoryInfo directory = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
string fileName = Path.Combine(directory.FullName, "secretmessage.txt");

{
    using (var reader = new StreamReader(fileName));
    Console.Contents(fileName);
}   

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! First, the curly braces aren't needed. But secondly Console.Contents is not defined as indicated by the compiler error when trying to compile this. What you're looking for is Console.WriteLine(). Give it another shot with these hints in mind! Good luck! :sparkles:

Calvin Secrest
Calvin Secrest
24,815 Points

Thank you for your assistance

HIDAYATULLAH ARGHANDABI
HIDAYATULLAH ARGHANDABI
21,058 Points

let me help you

DirectoryInfo directory = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
string fileName = Path.Combine(directory.FullName, "secretmessage.txt");
using (var reader = new StreamReader(fileName))  
{
    Console.WriteLine(reader.ReadLine());
}