小编Sim*_*mon的帖子

读取文件流阅读器

我的错误是什么,因为我无法在互联网上找到与我正在做的事情相符的例子,或者至少我不确定它是否存在?

我遇到的问题是它不喜欢

hexIn = fileStream.Read()
Run Code Online (Sandbox Code Playgroud)

码:

FileStream fileStream = new FileStream(fileDirectory, FileMode.Open, FileAccess.Read);
String s;

try
{
    for (int i = 0; (hexIn = fileStream.Read() != -1; i++)
    {
        s = hexIn.ToString("X2");
        //The rest of the code
    }
}
finally
{
    fileStream.Close();
}
Run Code Online (Sandbox Code Playgroud)

c# filestream

4
推荐指数
1
解决办法
2万
查看次数

C#一次读取文件为十六进制一个字节

可能重复:
使用IO在C#中读取十六进制

嗨,我是Java的新手,我在过去的两个小时里一直处于简单的困境中,或者应该如何想知道是否有人会帮助我:)

在Java中,我使用代码beleow读入一个文件,它使用十六进制读取给定文件,一次一个字节?在C#中这样做的方法是什么?

int hexIn;

File file = new File(filePath);

FileInputStream fis = new FileInputStream(file);

 for(int i = 0; (hexIn = fis.read()) != -1; i++){

   String s = Integer.toHexString(hexIn);
   if(s.length() < 2){
     s = "0" + Integer.toHexString(hexIn);
    }
}
Run Code Online (Sandbox Code Playgroud)

对不起,如果这看起来很笨,我只是卡住了!提前谢谢了!

:)

c# hex file

1
推荐指数
1
解决办法
7717
查看次数

标签 统计

c# ×2

file ×1

filestream ×1

hex ×1