Areas > Languages > VBScript
Areas > ASP / ASP.Net > Functions
Areas > ASP / ASP.Net > File & data transfer
Areas > WSH
to read and write files, because these languages were designed as
"safe" client-side programming languages. Denied access to file system is it's
1. ADODB.Stream object
ADODB.Stream is a first object you can use to read/write text and binary files. The object is included in ADO 2.5 and later.
ADODB.Stream let's you also save text data and let's you specify charset (codepage) for text-to-binary data conversion (against of Scripting.TextStream object).
2. Scripting.FileSystemObject object
You can also use TextStream object from Scripting library to store binary data. This function may be useable on servers without ADO installed. This function uses BinaryToString from Convert a binary data (BinaryRead) to a string by VBS article.
3. WinHttpRequest (XMLHTTP, ServerXMLHTTP) and remote files.
Microsoft created several
objects, which let's
you read remote binary and text
files. First of them was Microsoft.XMLHTTP - the object is using WinINET API,
so there is no good idea to use it on server-side ASP script. Thanks to WinINET
API, XMLHTTP has a great functionality - it supports any URL - http, https,
ftp and gopher. The URL looks like protocol://usename:password@server/folder/file?parameters.
You can use ResponseText property to get the document data as a string (or BinaryToString VBS function).
for 'Work with binary files in VBSscript - read and write local and remote files' articleDownload multiple files in one http requestThis article shows a way to download multiple files in one http request. It let's you send an HTML page along with image preview, prepare more files for download and send the files as one data stream. One request, one authentication per multiple files.
Read and write SQL image data, store binary file to sql table.Store and read SQL image/binary data using functions in this article. You can store local or remote files in an sql table along with a description and other fields.
Post binary data to URL from WSH/ASP/VBA/VBScript.Two methods to POST binary or string data to external URL and read results sent from a script on the URL.
Convert a binary data (BinaryRead) to a string by VBSThis article, demonstrates several versions of source VBS code you can use to work with binary data in ASP and convert the data to a String format.
Create and work with binary data in ASP/VBScriptLets you convert/create binary data in ASP to use the data for BinaryWrite/BinaryRead.
Write to text file from MS-SQL.Stored procedure which enables write text data directly to the file.
Copyright and use this code
The source code on this page and other samples at http://www.motobit.com/tips/ are a free code, you can use it as you want: copy it, modify it, use it in your products, ...
If you use this code, please:
1. Leave the author note in the source.
2. Link this sample from you page.
<A Href="http://www.motobit.com/tips/detpg_read-write-binary-files/" Title="Reading and writting binary and text files is a first task you will need to solve in server-side ASP. This article contains several VBS functions which let's you store data to local disk and read local or remote (http) files." >Work with binary files in VBSscript - read and write local and remote files</A>
© 1996 - 2014 Antonin Foller, Motobit Software | About, Contacts | (Find us on Google+)