Home > Back-end >  How to use the API file operation, realize the release documents the tail part of the space, namely
How to use the API file operation, realize the release documents the tail part of the space, namely

Time:09-22

How to use the API file operation, realize the release documents the tail part of the space, namely after writing the file size, less than written before?

I now want to operate a file already exists, assuming that the file size of 3 k,
And I want to write the contents of the accounts for only 2 k,
This in FileWrite API functions, such as how to realize?

I know that after the first remove to Create,
But it should be low efficiency,
I want to delete the end-of-file spare parts directly, how should do?

CodePudding user response:

CreateFile to open the file, after you have written in FileWrite, reoccupy Windows API: SetEndOfFile, finally the CloseHandle
  • Related