csharp: how to write stuff to the beginning of a file

Another off a C# irc channel.

Now, admittedly, this is assuming a small enough file that reading the whole thing into a string in memory isn’t a big deal 🙂 If big files are involved, StreamWriter and StreamReader out to a temp file then swap with File.Delete and File.Move

07:20 [ nas–] Can someone please tell me how i can Append Text to the Top of a txt file??
08:40 [ Flav_] nas–: contents = File.ReadAllText; contents = stuff + contents; File.WriteAllText

Advertisements