简体   繁体   中英

Read binary file from C# on NodeJs?

Is it possible to read a binary file made on C# (Unity App), using NodeJS?

Am using Node-Webkit and i've never used anything other than c# to read/create my binary files to save stuff, is there a type convention or a key that i need to know to be able to read and build the binary data from nodejs perspective so i can print it in a interface?

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

Here is an example of fs.read() -ing the first 100 bytes from a file descriptor returned by fs.open() :

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));
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM