Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:17:48+00:00 2026-06-07T15:17:48+00:00

The following code is used to save a CSV string, however, if I save

  • 0

The following code is used to save a CSV string, however, if I save to an existing .CSV, instead of replacing the data, it only adds the new string to the data already there.
How do I remedy this? Is it something inherent to how the Stream.Write function works, or is this an idiosyncrasy of Excel and .CSV?

SaveFileDialog dialog = new SaveFileDialog();

dialog.AddExtension = true;
dialog.Filter = "CSV Files (*.csv)|*.csv|All Files (*.*)|*.*";
dialog.FilterIndex = 1;
dialog.Title = "Save As";
dialog.InitialDirectory = "C:\\";
dialog.CheckPathExists = true;
dialog.DefaultExt = ".csv";
dialog.ValidateNames = true;

if (dialog.ShowDialog() == DialogResult.OK)
{
    StreamWriter myStream = new StreamWriter(dialog.FileName, true);
    myStream.Write(//Function which returns a CSV-formmatted string//);
    myStream.Close();
    OpenFile(dialog.FileName);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:17:49+00:00Added an answer on June 7, 2026 at 3:17 pm
    StreamWriter myStream = new StreamWriter(dialog.FileName, false);
    

    http://msdn.microsoft.com/library/36b035cb%28v=vs.100%29

    the second parameter (bool append), is well described :

    append
    Type: System.Boolean
    Determines whether data is to be appended to the file. If the file exists and append is false, the file is overwritten. If the file
    exists and append is true, the data is appended to the file.
    Otherwise, a new file is created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the following code to download/save an image and open it later, but
I have used following code to convert string to json and parse it. String
i have used the following Code to save date into DB of Sqlite (
I used the following code to save what the user editing , the code
QFileDialog is used in my code like following: QFileDialog fileDlg; fileDlg.setFileMode(QFileDialog::AnyFile); fileDlg.setViewMode(QFileDialog::List); fileDlg.setNameFilter(Excel Files(*.csv));
Please check out my following code String jsonString = writer.toString(); JSONObject jsonObj = new
Update: I've added the following code: function TSettingsForm.AppDataPath: string; //CSIDL_APPDATA Individual user Data //CSIDL_COMMON_APPDATA
Can anyone save me? I have the following code: private List<string> GenerateTerms(string[] docs) {
I swear the following code used to work, even in IE7 but now i
The following code I used to replace .(dot) by ,(coma) while user inputing value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.