简体   繁体   English

如何从二进制文件中删除一些第一位

[英]how to remove few first positions from binary file

I've used an HEX editor to figure out that a encrypting made to a .WAV file is adding 16 blocks of empty 00's. 我使用了一个十六进制编辑器来确定对.WAV文件进行的加密将添加16个空白的00块。 I understood that the first 64 positions should be deleted and then the file is de-crypted. 我知道应该删除前64个位置,然后再解密文件。 After searching the site i couldn't find an example that will match my case, I just need to open the file and write it to another file without those first 64 positions. 在搜索站点之后,我找不到适合我的情况的示例,我只需要打开文件并将其写入没有前64个位置的另一个文件中即可。 Appreciate your help 感谢您的帮助

If you use 64byte buffer to copy the file, than you can skip the first one: 如果使用64byte缓冲区复制文件,则可以跳过第一个:

using(var originalFile = File.OpenRead("some file"))
using(var newFile = File.OpenWrite("some file"))
{

byte[] buffer = new byte[64];

    int readBytes= 0;
    int currentReaded = 0;
    do
    {
        currentReaded = originalFile.Read(buffer, 0, buffer.Length);
        readBytes += currentReaded; 

        if(readBytes > 64)
        {
            newFile.Write(buffer, 0, currentReaded);
        }

    } while (currentReaded == buffer.Length);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM