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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:32:20+00:00 2026-06-17T05:32:20+00:00

NOTE: I can’t use FileMode.Create or FileMode.Truncate because they would cause some unwanted problem

  • 0

NOTE: I can’t use FileMode.Create or FileMode.Truncate because they would cause some unwanted problem

 byte[] data = new UTF8Encoding().GetBytes(this.Box.Text);
                FileStream f = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
f.Write(data, 0, data.Length);
                f.Close();

This will append new text to the top of the old one. How can I overwrite everything?

  • 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-17T05:32:21+00:00Added an answer on June 17, 2026 at 5:32 am

    your code

    byte[] data = new UTF8Encoding().GetBytes(this.Box.Text);
    FileStream f = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
    f.Write(data, 0, data.Length);
    f.Close();

    how come you can’t do something like this..? please explain why you can’t use FileMode.Create

    byte[] data = new UTF8Encoding().GetBytes(this.Box.Text);
    using(Stream f = File.Open(path, FileMode.Write)) 
    {
       f.Write(data, 0, data.Length);
    }
    

    you could also do something like the following

    1. Let the users write to the same file
    2. capture the users Machine Name or User Id then
    2. write a line in your file like this 
    
    strSeprate = new string('*',25); 
    //will write to the file "*************************";
    f.Write(strSeprate);
    f.Write(Machine Name or UserId);
    f.Write(data);
    f.Write(DateTime.Now.ToString());
    f.Write(strSeprate);
    

    just an idea..

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

Sidebar

Related Questions

Can anyone help with an odd Ruby Gem problem I'm having - note I've
How can I remove the unwanted whitespace in following example? Note 1. that there
namespace WcfService1 { // NOTE: You can use the Rename command on the Refactor
Note: I can't use anything that is default. I am trying to make a
I want save user note which can not be remove if they update app
Is there way to list all printers on a domain? note:I can use delphi
As images say more than 1000 words, here's my problem (note: I can't post
I have an entity Tag and an entity Note . A note object can
Note: The Data schema can not be changed. I'm stuck with it. Database: SQLite
Note: when I say static string here I mean memory that can not be

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.