gpt4 book ai didi

c# - 从 NodeJs 上的 C# 读取二进制文件?

转载 作者:搜寻专家 更新时间:2023-11-01 00:07:06 25 4
gpt4 key购买 nike

是否可以使用 NodeJS 读取在 C#(Unity App)上制作的二进制文件?

我正在使用 Node-Webkit,除了 c# 之外,我从未使用过任何其他东西来读取/创建我的二进制文件来保存东西,是否有类型约定或我需要知道的 key 才能读取和构建从 nodejs 角度看二进制数据,以便我可以在界面中打印它?

public static void Save() {
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create (Application.persistentDataPath + "/savedGames.gd");
bf.Serialize(file, SaveLoad.savedGames);
file.Close();
}

最佳答案

这是 fs.read() 的示例 - 从 fs.open() 返回的文件描述符中读取前 100 个字节:

var fs = require('fs');

fs.open('file.txt', 'r', function(error, fd) {
if (error) {
console.log(error.message);
return;
}
var buffer = new Buffer(100);
fs.read(fd, buffer, 0, 100, 0, function(err, num) {
console.log(buffer.toString('utf-8', 0, num));
});
});

关于c# - 从 NodeJs 上的 C# 读取二进制文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32297802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com