General discussion

Help! Need to write to end of file

Hello
I'm using StreamWriter to write data to a file. However every time it writes new data, it overwrites what's already there. Can someone help me make it so that it writes on the next line after what's already there? Go to end of file?

I'm very new to scripting.

Thanks

Discussion is locked

Follow
Reply to: Help! Need to write to end of file
PLEASE NOTE: Do not post advertisements, offensive materials, profanity, or personal attacks. Please remember to be considerate of other members. If you are new to the CNET Forums, please read our CNET Forums FAQ. All submitted content is subject to our Terms of Use.
Reporting: Help! Need to write to end of file
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Comments
- Collapse -
Always keep the documentation handy...

For instance, the StreamWriter documentation shows that there are overloaded constructors that let you specify whether the content should be appended to the file or overwrite it. As you spend time developing in a language you will memorize most of the common functionality, but even the most experienced developers keep the documentation handy. Keep that in mind and you can do just about anything you put your mind to.

Hope this helps,
John

- Collapse -
Thanks

Hello, thank you so much, your reply fixed it for me Happy

- Collapse -
Reposted for jonewatson

But I left out the ad-link to a programming company.

Kees
--------------------

I think this cause may be the overloaded constructor that let you specify whether the content should be appended to the file or overwrite it.
The first step to creating a new text file is the instantiation of a StreamWriter object. The most basic constructor for StreamWriter accepts a single parameter containing the path of the file to work with. If the file does not exist, it will be created. If it does exist, the old file will be overwritten.

CNET Forums

Forum Info