gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 20:33:51 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Read hex in C# using IO

嗨,我是从 Java 开始接触 C# 的新手,过去两个小时我一直在做一些简单的事情,或者应该是什么,想知道是否有人会帮助我:)

在 Java 中,我使用下面的代码读取文件,它使用十六进制读取给定文件,一次一个字节?在 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);
}
}

抱歉,如果这看起来很蠢,我只是被困住了!非常感谢!

:)

26 4 0
文章推荐: c# - 将 List 转换为另一个 List
文章推荐: matlab - 矩阵的幂
文章推荐: html - 水平对齐
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com