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 8047201
In Process

The Archive Base Latest Questions

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

When is it necessary to flush a file? I never do it because I

  • 0

When is it necessary to flush a file?
I never do it because I call File.Close and I think that it is flushed automatically, isn’t it?

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

    You’ll notice that an os.File doesn’t have a .Flush() because it doesn’t need one because it isn’t buffered. Writes to it are direct syscalls to write to the file.

    When your program exits(even if it crashes) all files it has open will be closed automatically by the operating system and the file system will write your changes to disk when it gets around to it (sometimes up to few minutes after your program exits).

    Calling os.File.Sync() will call the fsync() syscall which will force the file system to flush it’s buffers to disk. This will guarantee that your data is on disk and persistent even if the system is powered down or the operating system crashes.

    You don’t need to call .Sync()

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

Sidebar

Related Questions

Empirically it seems that flush() is not necessary after findAndUpdate() , I just couldn't
Is it necessary to close the connection of a tcplistener or tcpclient after every
My question is about writing a video file to the hard drive that is
I am trying to clear up an issue that occurs with unflushed file I/O
not necessary an UML diagram, just a simple way to graphically document the relations
I installed all the necessary packages for running GUI programs in Cygwin. Right now,
Is it necessary to check for nullptr after allocating an object using gcnew?
What references are necessary to have fluent nhibernate work with mysql. I have downloaded
What are the necessary items need from creating a deployment project for a windows
Why is it necessary to keep visited flag for iterative post order traversal and

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.