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 trialCalvin Secrest
24,815 PointsInside 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.
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
Treehouse TeacherHi 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!
HIDAYATULLAH ARGHANDABI
21,058 Pointslet 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());
}
Calvin Secrest
24,815 PointsCalvin Secrest
24,815 PointsThank you for your assistance