Binary File

Deleting from the file

Page 1 of 1

5 Replies - 1816 Views - Last Post: 22 September 2010 - 11:26 AM Rate Topic: -----

#1 kmoffitt  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 30-August 10

Binary File

Posted 14 September 2010 - 09:33 AM

What is the proper procedure to "Delete" information either from the end of a Binary File or from the middle of a File. Have tried inserting "" and " " but neither seems to work... Thanks for your help
Keith
Is This A Good Question/Topic? 0
  • +

Replies To: Binary File

#2 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,778
  • Joined: 26-March 09

Re: Binary File

Posted 14 September 2010 - 10:08 AM

One way would be to "copy" the bits you need (i.e.: read it in and write it out, discarding the bits you don't need).

This will do as you you said you wanted to do, but depending on what the binary file is, it may not achieve what you want, for example if it's an exe file, deleting bits from here there and everywhere would probably break it.

If you give some more details of the what the file is and what your actually trying to achieve and the code you've written so far, your more likely to get a response tailored to what your after.
Was This Post Helpful? 0
  • +
  • -

#3 Guest_kmoffitt*


Reputation:

Re: Binary File

Posted 22 September 2010 - 06:51 AM

this is deleting a "password"; sometimes to just delete or remove the password and other times to replace the password with a shorter or longer one...

View Postmaj3091, on 14 September 2010 - 09:08 AM, said:

One way would be to "copy" the bits you need (i.e.: read it in and write it out, discarding the bits you don't need).

This will do as you you said you wanted to do, but depending on what the binary file is, it may not achieve what you want, for example if it's an exe file, deleting bits from here there and everywhere would probably break it.

If you give some more details of the what the file is and what your actually trying to achieve and the code you've written so far, your more likely to get a response tailored to what your after.

Was This Post Helpful? 0

#4 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,778
  • Joined: 26-March 09

Re: Binary File

Posted 22 September 2010 - 07:12 AM

View Postkmoffitt, on 22 September 2010 - 05:51 AM, said:

this is deleting a "password"; sometimes to just delete or remove the password and other times to replace the password with a shorter or longer one...

View Postmaj3091, on 14 September 2010 - 09:08 AM, said:

One way would be to "copy" the bits you need (i.e.: read it in and write it out, discarding the bits you don't need).

This will do as you you said you wanted to do, but depending on what the binary file is, it may not achieve what you want, for example if it's an exe file, deleting bits from here there and everywhere would probably break it.

If you give some more details of the what the file is and what your actually trying to achieve and the code you've written so far, your more likely to get a response tailored to what your after.



This again goes back to my original statement of "it depends on what the file is".

Is it you're own binary file?

Did you write the program that reads it?

For example, if the program trying to read the file, reads it into a UDT, where the password field is expected to be a certain length, then you can't make it longer. If you make it shorter, you will need to pad it with something, but then do you pad it left or right? Do you understand what I'm trying to say?

An explanation of one way of doing what you wanted was given in my previous post, so you can quite easily achieve the aim of your question. Whether it works will be dependant on the file and the programs that utilise it.

Have a go at writing some code and see how you get on.
Was This Post Helpful? 0
  • +
  • -

#5 Guest_kmoffitt*


Reputation:

Re: Binary File

Posted 22 September 2010 - 08:54 AM

Yes this is my binary file; the password in this case is at the end of the file. I always know the length of the old password or the new one or the one I am deleting; it is held in a variable and I know the length of the varible. I don't know how to take the old password out of the file and just leave "nothing" in its place...
Thanks

View Postmaj3091, on 22 September 2010 - 06:12 AM, said:

View Postkmoffitt, on 22 September 2010 - 05:51 AM, said:

this is deleting a "password"; sometimes to just delete or remove the password and other times to replace the password with a shorter or longer one...

View Postmaj3091, on 14 September 2010 - 09:08 AM, said:

One way would be to "copy" the bits you need (i.e.: read it in and write it out, discarding the bits you don't need).

This will do as you you said you wanted to do, but depending on what the binary file is, it may not achieve what you want, for example if it's an exe file, deleting bits from here there and everywhere would probably break it.

If you give some more details of the what the file is and what your actually trying to achieve and the code you've written so far, your more likely to get a response tailored to what your after.



This again goes back to my original statement of "it depends on what the file is".

Is it you're own binary file?

Did you write the program that reads it?

For example, if the program trying to read the file, reads it into a UDT, where the password field is expected to be a certain length, then you can't make it longer. If you make it shorter, you will need to pad it with something, but then do you pad it left or right? Do you understand what I'm trying to say?

An explanation of one way of doing what you wanted was given in my previous post, so you can quite easily achieve the aim of your question. Whether it works will be dependant on the file and the programs that utilise it.

Have a go at writing some code and see how you get on.

Was This Post Helpful? 0

#6 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,778
  • Joined: 26-March 09

Re: Binary File

Posted 22 September 2010 - 11:26 AM

In that case, if you know the length, then you can read it byte by byte and write it out for the length of the original file - length of your password.


Have a look at THIS tutorial, maybe it will get you started.

Have a go at some code and post back if you have problems.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1