Monday, July 05, 2004

Work with binary files in VBSscript - read and write local and remote files

Work with binary files in VBSscript - read and write local and remote files: " VBScript and JScript/JavaScript do not have native functions/commands to read and write files, because these languages were designed as 'safe' client-side programming languages. Denied access to file system is it's primary feature.
Server-side ASP code and applications has another work requirements, file system access (read/write files) is at first of them. The only way to work with files is to use built-in or external ActiveX or COM object.
Microsoft solved this problem using FileSystemObject - but the object cannot read/write binary files (There is some work-around to use it to store binary files also - see code bellow - but you can only read text files with this object).
Many people work on this simple task in C++, VBA, Delphi and other languages to create object, which let's you read binary data. One of this great objects is our ByteArray class (member of ScriptUtilities library), which let's you read and write binary files, work with binary data using blocks, convert it to/from Unicode string using more than 100 code pages, convert to hex string, etc."

No comments: