I want to insert my string to the beginning of the file. But there is no function to append in beginning in stream writer. So how should I do that ?

My code is :

string path = Directory.GetCurrentDirectory() + "\\test.txt";
StreamReader sreader = new StreamReader(path);
string str = sreader.ReadToEnd();
sreader.Close();

StreamWriter swriter = new StreamWriter(path, false);

swriter.WriteLine("example text");
swriter.WriteLine(str);
swriter.Close();

But it doesn't seem optimized. So is there any other way ?

Edit
Report