+ 2

How can I Append some text to the beginning of file?

How can I Append some text to the beginning of file? File.AppendAllText() method appends text to the end of file. How can I append to beginning?

12th Dec 2017, 9:33 AM
Amadeus
Amadeus - avatar
3 Réponses
+ 7
string currentContent = String.Empty; if (File.Exists(filePath)) { currentContent = File.ReadAllText(filePath); } File.WriteAllText(filePath, newContent + currentContent ); may be by this you can do that
12th Dec 2017, 9:40 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
Try reading in the file and storing it in a variable then write over the file with the new text and append the stored.
12th Dec 2017, 9:40 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
thanks for help
12th Dec 2017, 9:49 AM
Amadeus
Amadeus - avatar