Add text to existing text file

I need to add text (not a line) to an existing text file, using C#. I can create the file, and write text to it, but when I have to append text, for some reason, it fails. I can append a line, but I don't need to append a line. I just need to append some text. I am passing a boolean to force the creation of a new file the first time it runs. I am also passing the filepath, and the text to be appended. Code is listed below.
NOTE: commented code are all of the different attempts that failed:

Your routine works fine, but the first time the program runs, if the file already exists, I need to overwrite the file, and create a new one. That is the reason I pass the boolean flag to my routine. I tried to add your code to my method, and I had the same error. Can you recommend a way to create a new file + write text the first time, and to append text (NOTE: not to append a line) to the existing file, thereafter. Thanks.

Hi Serkan:
Thanks for the zip files, but I was not able to unzip them (not sure why). Are there any special instructions? I tried doing a backup, and I tried skipping the backup, and either way, I was not able to read/run anything.

Never mind Sknake:
I finally figured out what I was doing wrong. Your solution added to my code works perfectly. Thanks for the help!!

join our request for making sknake a featured poster then.(go to geeks lounge and you will see the thread "congritulations...", add something to support us)

i dont know what is wrong with the attachment that you couldnt open. maybe i have to set some password since our company does something when you attach something without a password which i think salts the contents or so.

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...