- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在将一些 C++ 代码转换为 C#,我试图弄清楚如何在我的 C# 应用程序中编写和遵循 C++ 代码并让它做同样的事情:
fread(&Start, 1, 4, ReadMunge); //Read File position
我尝试了多种方式,例如使用 FileStream:
using (FileStream fs = File.OpenRead("File-0027.AFS"))
{
//Read amount of files from offset 4
fs.Seek(4, SeekOrigin.Begin);
FileAmount = fs.ReadByte();
string strNumber = Convert.ToString(FileAmount);
fileamountStatus.Text = strNumber;
//Seek to beginning of LBA table
fs.Seek(8, SeekOrigin.Begin);
CurrentOffset = fs.Position;
int numBytesRead = 0;
while (Loop < FileAmount) //We want this to loop till it reachs our FileAmount number
{
Loop = Loop + 1;
//fread(&Start, 1, 4, ReadMunge); //Read File position
//Start = fs.ReadByte();
//Size = fs.ReadByte();
CurrentOffset = fs.Position;
int CurrentOffsetINT = unchecked((int)CurrentOffset);
//Start = fs.Read(bytes,0, 4);
Start = fs.Read(bytes, CurrentOffsetINT, 4);
Size = fs.Read(bytes, CurrentOffsetINT, 4);
Start = fs.ReadByte();
}
}
我一直遇到的问题是 Start/Size
没有保存我需要的 4 个字节的数据。
最佳答案
如果您正在读取二进制文件,您可能应该考虑使用 BinaryReader .这样你就不必担心将字节数组转换为整数或其他任何东西。例如,您可以简单地调用 reader.ReadInt32
来读取一个 int。
关于C# 相当于 fread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8632974/
我有以下代码: int main() { char* pedal[20]; char* pedal2[20]; for (int i = 0; i < 20; i++)
我想用 in.wav 文件中的数据填充 hdr (结构)变量,并且我想复制 in 的前 64 个字节。 wav 文件转换为另一个文件 (out.wav)。 但是!当第二次使用fread()时,它开始从
我有一个由 1and1 托管的网站 - 他们没用!由于某种原因,他们提供的备份脚本不再有效,他们无法为我提供答案!所以我想我会自己写,这是我的代码: if (file_exists('backup
我正在尝试从文件中读取并将其复制到另一个文件。我正在网上查看一些代码,我似乎注意到有些人以这种方式声明 fread: fread (buffer, 1, 1000, src) 一些这样 fread (
当我是“男人的恐惧”时,我得到了: RETURN VALUE fread() and fwrite() return the number of items successfully read or
从文件中读取整数值时,覆盖率检查给出以下错误 调用函数“fread”会污染参数“readval” //coverity note: Calling function "fread" taints ar
为了更清楚地说明这一点,我将放置代码示例: $file = fopen('filename.ext', 'rb'); // Assume $pos has been declared // metho
尝试转换此 matlab 代码: fid = fopen([fpath, '/file.bin'],'rb'); content = fread(fid, 11,'single'); 我当前的尝试如下
假设我有: FILE* fp = fopen("myfile.bin", "r"); char something[30]; fread(something,sizeof(char)*30,1,fp)
fwrite 一个整数取决于字节序,但是有没有一种方法可以将一个整数 0x00000004 写入一个文件,这样无论它运行在什么机器上,它都可以始终被读取为 0x00000004。 一个想法是始终按照特
所以我尝试将此类 Matlab 代码转换为 C++: ss = 'file.mask' fp = fopen(ss, 'rb'); sx = fread(fp, 1, 'int32') sy = f
使用 C,可以使用函数 fread 来读取以 null 结尾的字符串吗? 我必须读取一个以 ip 开头的文件,该文件是 4 个无符号字符,后跟一个描述空终止字符串数的整数。之后,我需要读取字符串,直到
> fread('col1,col2\n') Empty data.table (0 rows) of 2 cols: col1,col2 > fread('col1,col2\n5,4') c
我正在尝试使用 data.table 将文件读入 R/fread .一些字段有前导零,我只想将数据作为字符读取并手动修复它们。但是我不知道如何将其传达给 fread .我正在尝试这个,它像往常一样分配
fread来自 data.table包一般可以在读取文件时自动确定列分隔符( sep )。 例如,这里fread自动检测 |作为列分隔符: library(data.table) fread(past
使用 fread,如何读取包含行名和列名的 CSV 文件。 我尝试了以下操作,但它没有正确读取行和列名称。 csv 文件看起来像(其中 C1、C2、C3 是列名,r1、r2、r3 是行名) input
我遇到了这样的文件: COL1 COL2 COL3 weqw asrg qerhqetjw weweg ethweth
我正在尝试使用 fread 读取表格。 txt 文件具有如下所示的文本: "No","Comment","Type" "0","he said:"wonderful|"","A" "1","Pr/ "
我正在尝试使用从 Apple 移动性报告生成的 csv,可以找到 here . 现在一切正常,我能够按预期获得 .csv,它看起来像这样的文字: csvtxt <- "geo_type,region,
我在 data.table (1.8.8, R 3.0.1) 中使用 fread 试图读取非常大的文件。 有问题的文件有 313 行和约 660 万列数字数据行,文件大小约为 12GB。这是具有 51
我是一名优秀的程序员,十分优秀!