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

  • SEARCH
  • Home
  • 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 8047763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:12:11+00:00 2026-06-05T06:12:11+00:00

I use this code to save my xml file. SaveFileDialog saveFileDialog1 = new SaveFileDialog();

  • 0

I use this code to save my xml file.

SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.DefaultExt = ".FFDATA";
saveFileDialog1.Filter = "Form|*.FFDATA";
saveFileDialog1.FileName = "A_"+code;//here code is a generated number, always unique

Stream myStream;

if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
    if ((myStream = saveFileDialog1.OpenFile()) != null)
    {
        StreamWriter wText = new StreamWriter(myStream);
        wText.Write(result.ToString());

        myStream.Close();
    }
}

However when I open the file, the text inside is cut in some place and the second part of it is missing. (I breakpointed wText.Write(result.ToString()); and result.ToString() is as I expect – a normal text.

Then I tried putting wText.Write("Test?"); and nothing got saved into a file, however the file itself appeared.

So no matter how short the text I am trying to save, I get at least some data missing.

Question: what am I doing wrong?

P.S. I found this example and modified slightly to suit my needs.

  • 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-05T06:12:12+00:00Added an answer on June 5, 2026 at 6:12 am

    The contents are probably not flushed. This is easily avoided by calling Flush yourself or using a ‘using’ block which also handles disposing/closing etc.

    using (StreamWriter wText = new StreamWriter(myStream))
    {
      wText.Write(result.ToString());
      //wText.Flush(); //this should not be needed because close will flush
    }
    

    Note the absence of any .Close() here… disposing the streamreader via the using block takes care of that for you, and makes sure it’s done correctly.

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

Sidebar

Related Questions

hi i use this code for save text in database function commenttext() { var
I use this code: $(img.cloudcarousel).each(function(i, e){ coords[i] = $(e).offset(); }); to save the position
I Save An onject into a xml file with serialize like this: FileStream stream
How can I access this element: <input type=submit value=Save as XML onclick=some code goes
Here is my XML file <?xml version=1.0 encoding=utf-8 ?> <storage> <Save Name =Lifeline> <Seconds>12</Seconds>
I use this code to download a link and I want to save a
use this code, in the Preferences activity, to know when the reset preference has
I use this code to redirect user to a particular app in the Market:
i use this code for exporting gridview to Excel in asp.net - c# .....but
I use this code on my wordpress plugin to return the src of the

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.