Shoutbox

[Help] What is the best way to read binary file ?? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Help] What is the best way to read binary file ?? (/showthread.php?tid=90226)

[Help] What is the best way to read binary file ?? by N0na on 04-18-2009 at 09:14 AM

hey again :$



sorry for the new thread , but i've searched alot and didn't find what i want =)

im wondering about the best way to read/write binary files ,

i want that for saving and reading sittings in an own crypting method , so user can't edit or play with the sittings file.

i thought about ReadFile API and FSO , but i think ReadFile supports binary and FSO don't , because FSO functions called "OpenAsTextStream" and that isn't a normal text file =\

so , if there is any piece of code of reading a files into DataBloc object , we Appreciate that .8-|


sorry if the answer exist before , but i couldn't get it ,


thanks in advanced ...(Y)


RE: [Help] What is the best way to read binary file ?? by matty on 04-18-2009 at 01:06 PM

Eljay's reply to unicode problem


RE: [Help] What is the best way to read binary file ?? by N0na on 04-18-2009 at 02:00 PM

[thanks] for ur post :)


i'l check wht i can do with it , sorry i didn't search alot , but there must be a thread for "Files reading/writing" and for registry , and so :)

have a nice day


sorry ,

i used the code posted , but the file size gives me the file till the 1st null char

because variables are null terminated or something like that =|


is there any other way to do what i want wich is reading binary file into datablock ?

have a nice day.
RE: [Help] What is the best way to read binary file ?? by MeEtc on 04-19-2009 at 01:41 AM

I have a helper script written by Volv that works with binary data. I'll post/attach when I get home.

These should help.

JScript code:
function binReadFile(filePath)
{
    var fstream = new ActiveXObject("ADODB.Stream");
    fstream.Type = 1;
    fstream.Open;
    fstream.LoadFromFile(filePath);
    return fstream.Read;
}
 
function binWriteFile(binData, filePath)
{
    var fstream = new ActiveXObject("ADODB.Stream");
    fstream.Type = 1;
    fstream.Open;
    fstream.Write(binData);
    fstream.SaveToFile(filePath, 2);
    fstream.Close;
}
 
function asciiReadFile(filePath)
{
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var contents = fso.OpenTextFile(filePath, 1, 0).ReadAll();
    return contents;
}
 
function asciiWriteFile(strData, filePath)
{
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var txtfile = fso.CreateTextFile(filePath, true);
    txtfile.Write(strData);
    txtfile.close();
}
 
function GetFileSize(filePath)
{
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    if(fso.FileExists(filePath)) {
        var file = fso.getFile(filePath);
        return file.size;
    } else {
        return -1;
    }
}