Appending a file in C#

Hi folks ,


I want to know how to append a file in C#,it should not delete the original content of the file . How to do it for beginning of a file , i am doing this for a log file .

Replies

  • MaRo
    MaRo
    File.AppendText(filepath, text);
  • ark
    ark
    I have tried its working but its appending at the end of file but in my case i need to append to beginning of the file without altering the contents of the file .
  • gaurav.bhorkar
    gaurav.bhorkar
    ark
    I have tried its working but its appending at the end of file but in my case i need to append to beginning of the file without altering the contents of the file .
    Lets say we have two files, file1, file2.

    If you want contents of file1 to appear in beginning, then append file1 with file2.
    Else if you want contents of file2 to appear in the beginning, then append file2 with file1.

    You can always rename a file.
  • MaRo
    MaRo
    Add the text to a String array, reverse it, set a loop that appends the text to the file.
  • ark
    ark
    Thank you guys
  • ankesh.cs2007
    ankesh.cs2007
    same as gaurav????

You are reading an archived discussion.

Related Posts

Hi guys, I have 2 analog inputs and 2 digital inputs that I am hoping to sample remotely, so I have been looking at wireless cable solutions that are low...
i am a 3rd year student of ece dept...i m doing a project on this topic.....i am seeking someone's help to understand the VHDL program stepwise,which is listed below.... --...
hi, i am doing simulation of my project related to grid computing, when i run the simulation following error occurs Exception in thread "main" eduni.simjava.Sim_exception: Sim_entity: Entity names can't contain...
Hey people.....i need some help......please can you tell me how to drive a servomotor using a PLC.Im in desperate need of help......all i want to know is 1.Which kind of...
I am doing project on interleave division multiple access(IDMA) . for that i need concepts how generate turbo codes and how to decode it. I have write a 'c' program...