Added: 2 years ago
From: steamisM50
Views: 2,587
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (5)

Sign In or Sign Up now to post a comment!
  • hey guys maybe i miss somthing but does anyone know how use this to write a Console.Writeline into a txt file.

  • @messi996 You have to open up a steam and do Stream.writeline essentially

  • sr.ReadToEnd().Split('\n') is horribly inefficient and wrong (on windows CrLf files).

    Why not simply use sr.ReadLine? Convert.ToInt32 and family have a load of assumptions about current culture (locale) and will not only break, but silently interpret into the _wrong_ values if you don't specificly make sure what format is being parsed.

    Other mechanisms (e.g. Xml) nicely prevent this kind of mess, and you can always use .NET serialization with formatters if you need bleeding performance

  • @wwwsant This was an extension onto my previous saving out into a text file code tutorial. It wasn't meant as anything super efficient, just talking about things out there.

    Problem with sr.ReadLine, is you don't have as exact control over what you are reading when. Now, I don't thing it was a problem here, but you get my point.

    System.Convert.ToInt32 is regional, if in your country, you use commas for decimals, it will work. Only problem I see with that, is if you have english code....

  • @wwwsant But again, this wasn't supposed to be anything like, "Oh, this is the best way to do it!" it was, "Oh, well, before we did it this long way, this time lets do it the short and much easier route.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more