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 trialshawn khah
15,082 Pointshelp plz
Challenge Task 2 of 2
Inside the using block, write the contents of the first line of the file to the Console. Bummer! Did you write the contents of the file to the Console? Restart Preview Get Help Recheck work 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.WriteLine();
}
1
DirectoryInfo directory = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
2
string fileName = Path.Combine(directory.FullName, "secretmessage.txt");
3
using (var reader = new StreamReader(fileName))
4
{
5
Console.WriteLine();
6
}
DirectoryInfo directory = new DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
string fileName = Path.Combine(directory.FullName, "secretmessage.txt");
using (var reader = new StreamReader(fileName))
{
Console.WriteLine();
}
3 Answers
Igor Kletsov
7,556 PointsConsole.WriteLine(reader.ReadLine());
HIDAYATULLAH ARGHANDABI
21,058 PointsDirectoryInfo 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());
}
Rick Hoekman
9,494 PointsAs far as I can tell you are not passing the fileName into the WriteLine function.
Try this and see if it will pass..
Console.WriteLine(fileName);
shawn khah
15,082 Pointsit's not working Rick
Sam Baines
4,315 PointsShawn no offence but you have 12000 points on treehouse, surely you must of by now learnt to follow the wording of the code challenges fully and also learnt how to search the documentation for languages when you get stuck like this.
shawn khah
15,082 Pointsshawn khah
15,082 Pointsthank you so much igor