本文介绍了使用未知的dll从字符串写入一个字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

    int BufSize = 60000000;
    int BufSizeM1M = BufSize - 1000000;
    byte[] ByteBuf = new byte[BufSizeM1M];
    byte[] ByteBufVer = new byte[BufSizeM1M];
    using (WinFileIO WFIO = new WinFileIO(ByteBuf))
    {
        WFIO.OpenForWriting(path);
        Byte[] BytesInFiles = GetBytes(content);
        WFIO.WriteBlocks(BytesInFiles.Length);
    }

编辑:
这是原始代码我正在使用,试图修改它自己似乎失败了,所以我认为你可能会看看:

This is the original code i was working with, trying to modify it myself seems to fail, so i was thinking you guyz might have a look:

  int BufSize = 60000000;
  int BufSizeM1M = BufSize - 1000000;
  byte[] ByteBuf = new byte[BufSizeM1M];
  byte[] ByteBufVer = new byte[BufSizeM1M];
  int[] BytesInFiles = new int[3]
  using (WinFileIO WFIO = new WinFileIO(ByteBuf))
      WFIO.OpenForWriting(path);
      WFIO.WriteBlocks(BytesInFiles[FileLoop]);
  }

FileLoop 是一个$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
如何更改它来写入字符串的实际内容?

FileLoop is an int between 0-3 (the code was run in a loop)this was used for testing write speed.how would one change it to write actual content of a string?

WFIO dll是没有提供给我的,我似乎无法让它工作。
上面的代码是我可以得到的最好的,但是它写了一个填充空格的文件,而不是内容变量中的实际字符串。帮助请。

the WFIO dll was provided to me without instructions and i cannot seem to get it to work.the code above is the best i could get, but it writes a file filled with spaces instead of the actual string in the content variable. help please.

推荐答案

我想你可能会错过这一步。一旦你完成了:

I think you might be missing a step here. Once you've done:

Byte[] BytesInFiles = GetBytes(content); 

您不需要使用 BytesInFiles ?目前,您似乎正在编写 BytesInFiles 的块,当您创建它时,这些块将被初始化为包含所有零。

Won't you need to do something with BytesInFiles? Currently it seems as though you are writing chunks of BytesInFiles, which will have been initialized to contain all zeros when you created it.

编辑:这样的帮助?

Byte[] BytesInFiles = GetBytes(content); 

using (WinFileIO WFIO = new WinFileIO(BytesInFiles)) 
{ 
    WFIO.OpenForWriting(path);        
    WFIO.WriteBlocks(BytesInFiles.Length); 
} 

这篇关于使用未知的dll从字符串写入一个字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 21:17