Sign Up

Have an account? Sign In Now

Sign In

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 question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

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

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us
Home/ Questions/Q 1106
In Process
0x41
0x41

0x41

  • 1 Question
  • 1 Answer
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
0x41
Asked: December 18, 20202020-12-18T10:07:35+00:00 2020-12-18T10:07:35+00:00

tell me how to overwrite a binary file completely deleting its contents without deleting the file itself?

  • 0
tell me how to overwrite a binary file completely deleting its contents without deleting the file itself?

tell me how to overwrite a binary file completely deleting its contents without deleting the file itself?

Here I know that in other languages there are modes of opening a file, and there is a mode before writing there is a mode of overwriting.

I have already encountered such a problem, I have a code that stores the current open orders of the terminal in a file

   void WriteData(Order &arr[]){
      PrintFormat("Saving data to a file...");
      ResetLastError();
      int handle=FileOpen(save,FILE_READ|FILE_WRITE|FILE_BIN|FILE_COMMON);
      if(handle!=INVALID_HANDLE)
      {
         FileSeek(handle,0,SEEK_SET);
         FileWriteArray(handle,arr,0,WHOLE_ARRAY);
         PrintFormat("File saved successfully!");
         PrintFormat("Stored items in an array: %d",ArraySize(arr));
         FileClose(handle);
      }
   else
      Print("Failed to open the file, error ",GetLastError());
   }

Everything is fine I open two orders in the terminal and they are properly saved to a file

But the trouble is that when I close one order, I have only 1 structure with an active order in the array (I have already checked this) but
there is still a record of the old order in the file.

I suspect that when writing bytes smaller than in the file, it just writes them from the first byte and that’s it, and does not delete the old data.

How can this be defeated? what would the file be overwritten and written again, provided that I can not delete the file from the disk?

  • 1 1 Answer
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. 0x41

      0x41

      • 1 Question
      • 1 Answer
      • 0 Best Answers
      • 20 Points
      View Profile
      0x41
      2020-12-18T10:07:41+00:00Added an answer on December 18, 2020 at 10:07 am

      All I’m anyways stupid – there should have just removed the flag
      FILE_READ

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 504
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 673
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Users

    Brus Agell

    Brus Agell

    • 1 Question
    • 0 Answers
    pinupcasinoo

    pinupcasinoo

    • 1 Question
    • 0 Answers
    JamesSwics

    JamesSwics

    • 0 Questions
    • 0 Answers

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved