Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Novice problem c#

  • 16-11-2013 01:30AM
    #1
    Registered Users, Registered Users 2 Posts: 673 ✭✭✭


    Trying to print the contents of a file to the screen but the filename being passed is taken literally. "file.txt" wont open I just keep getting the string value "file.txt" given back to me, pulling me hair out at this stage. Any suggestions?

    string filename = ("file.txt");
    string contents = File.ReadAllText(filename);


Comments

  • Moderators, Society & Culture Moderators Posts: 17,642 Mod ✭✭✭✭Graham


    Any help:

    string contents = System.IO.File.ReadAllText(@C:\Users\Public\TestFolder\file);

    Get that working first, then look at passing the filename as a variable.


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Marsden


    Got it sorted cheers.


Advertisement