This works for me, but for small files. Probably it’s not a very good solution otherwise.
string currentContent = String.Empty;
if (File.Exists(filePath))
{
currentContent = File.ReadAllText(filePath);
}
File.WriteAllText(filePath, newContent + currentContent );
More Related Contents:
- Is there a way to check if a file is in use?
- Parsing CSV files in C#, with header
- What’s the fastest way to read a text file line-by-line?
- Easiest way to read from and write to files
- FileSystemWatcher vs polling to watch for file changes
- Saving any file to in the database, just convert it to a byte array?
- How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?
- How to both read and write a file in C#
- Download/Stream file from URL – asp.net
- How to read an entire file to a string using C#?
- The input is not a valid Base-64 string as it contains a non-base 64 character
- How to read the data in a wav file to an array
- Extremely Large Single-Line File Parse
- Closing a file after File.Create [duplicate]
- Efficient way to delete a line from a text file
- Sharing violation IOException while reading and writing to file C#
- Can I simply ‘read’ a file that is in use?
- StreamWriter.Write doesn’t write to file; no exception thrown
- Is there a faster way than this to find all the files in a directory and all sub directories?
- can I check if a file exists at a URL?
- Can you keep a StreamReader from disposing the underlying stream?
- Wait for file to be freed by process
- Unit Testing File I/O
- Can .NET load and parse a properties file equivalent to Java Properties class?
- How to get a MemoryStream from a Stream in .NET?
- Renaming a directory in C# [closed]
- Write to a file from multiple threads asynchronously c#
- Using StreamReader to check if a file contains a string
- how to handle spaces in file path if the folder contains the space?
- How to properly read and write a file using Windows.Storage on Windows Phone 8