Home > Software engineering >  VB how to delete the binary file to specify a data? thank you
VB how to delete the binary file to specify a data? thank you

Time:09-19

VB how to delete the binary file to specify a data? For example, a binary 1. Bin, how do I remove a 300 to 200 this period of data?
Move the back of the data to the front, the file is big, the speed is too slow, section by section to move, to move several times, is there a better way

CodePudding user response:

The file data to "move", must have to rewrite the file again,
If the file is "big", take a long time, it is inevitable,


At the current level of "hardware resources", a few hundred MB even on GB of files, can be a one-time read into memory (read an array of bytes);
Reading, the area of "skip" to delete, and then directly into a new file, or put the "old files to empty again write,"

CodePudding user response:

VB how to empty the current file all of the data, such as 1. Bin file, just put the file content fast to empty

CodePudding user response:

SetEndOfFile using the API function

CodePudding user response:

refer to the second floor wuganxiu response:
VB how to empty the current file all of the data, such as 1. Bin file, just put the file content rapidly emptying

I usually use the Open FileName for the output as # 1: close # 1
3/f the API method can also be said, but also cooperate with other "open file" API,
This API requires "file handle" parameters, must use OpenFile () or CreateFile () returns the handle,

CodePudding user response:

Binary mode, speaking, reading and writing can
Your file?

CodePudding user response:

refer to the second floor wuganxiu response:
VB how to empty the current file all of the data, such as 1. Bin file, just put the file content rapidly emptying

Delete the file, then open 1. Bin for the output as # 1 and then immediately close # 1 file to create a space,

CodePudding user response:

Any read and write files, files can be, the empty file can
Is the middle of the delete a file, such as delete 300 to 200 this period of data (100)
I put 300 the data behind the move to this location, 300 fuel to generate the size of the data has not changed, the reason is that the data while moving toward the front, but 100 to delete the below data,
How to delete the last 100 data below

CodePudding user response:

refer to 7th floor wuganxiu response:
any read document, can write files, empty files can be a
Is the middle of the delete a file, such as delete 300 to 200 this period of data (100)
I put 300 the data behind the move to this location, 300 fuel to generate the size of the data has not changed, the reason is that the data while moving toward the front, but 100 to delete the below data,
How to delete the last about 100 data

Read the N - 100 data, then write back cover, or delete the source file, write a new home

CodePudding user response:

Upstairs using SetEndOfFile this API truncated file is not to say that the back of the extra space

CodePudding user response:

refer to 7th floor wuganxiu response:
any read document, can write files, empty files can be a
Is the middle of the delete a file, such as delete 300 to 200 this period of data (100)
I put 300 the data behind the move to this location, 300 fuel to generate the size of the data has not changed, the reason is that the data while moving toward the front, but 100 to delete the below data,
How to delete the last about 100 data

Obvious is that before "rewrite the file data", you didn't take the file "empty"!!!!!!

CodePudding user response:

Don't have to "delete files", the way I have said on the 4th floor for an "empty operation",

CodePudding user response:

To remove between 200 and 300 bytes:
Will be from 1 to 199 save to file A, all content will be 301 to the end of the file save to file B
The last
Shell "CMD/copy c/b + b c", vbHide
The file C is requested,

CodePudding user response:

The
refer to 12 floor zhao4zhong1 reply:
to remove between 200 and 300 bytes:
Will be from 1 to 199 save to file A, all content will be 301 to the end of the file save to file B
The last
Shell "CMD/copy c/b + b c", vbHide
File petitions, C

Is "take off pants break wind!" "!!!!!

CodePudding user response:

The
refer to 12 floor zhao4zhong1 reply:
to remove between 200 and 300 bytes:
Will be from 1 to 199 save to file A, all content will be 301 to the end of the file save to file B
The last
Shell "CMD/copy c/b + b c", vbHide
File petitions, C

You this kind of treatment method, file A, B is not deleted???????

MD, now many of the APP is only know make rubbish, never cleaning up!
Just like you "just know shit, never wipe a" too many people...

CodePudding user response:

On the 14th floor Chen8013
reference response:
Quote: refer to 12 floor zhao4zhong1 reply:

To remove between 200 and 300 bytes:
Will be from 1 to 199 save to file A, all content will be 301 to the end of the file save to file B
The last
Shell "CMD/copy c/b + b c", vbHide
File petitions, C

You this kind of treatment method, file A, B is not deleted???????

MD, now many of the APP is only know make rubbish, never cleaning up!
Just like you "just know shit, never wipe a" too many people...

Don't try to the end of the elegant (because it is impossible)
And want to be in bad can't lousy can stall on reforming land!

Anticlimactic is the habit of layman,
Finish is gentleman's integrity,

CodePudding user response:

Big file into an array, is actually entered into a virtual memory, namely VB to create a buffer zone on the hard disk, because involves disk access, there will be a delay, or rather, read and write is more than the round,

Such a large section of the delete operation, faster is to open the two files, one input (source), and an output (temporary empty file), only a read write,

First read from the input source file, for example, want to delete the paragraph before the content, writing a new file, then delete the source file to read after the paragraph, once again or write to a new file for many times,

After close the two files, delete the source file, the name of the new file to the source file name,

CodePudding user response:

So-called modify delete file a certain position, is actually read the open files, a then 'a position before the modification and deletion of content + a + modification and deletion of the contents of the content of the modify delete position after b' save to file, and close the file. A, deleting a file, the file b changed its name to the same as the before file a name, that's it,
http://bbs.csdn.net/topics/391975224
  • Related