Solved

Convert vb.net binary write code to asp

Posted on 2006-11-10
4
1,181 Views
Last Modified: 2008-02-01
How would I covert the following vb.net code to asp code in order to create a binary file.              

Dim fs2 As New FileStream("c:\test.etu", FileMode.Create, FileAccess.Write)
            Dim sw As New BinaryWriter(fs2, System.Text.Encoding.Default)
            sw.Seek(0, SeekOrigin.End)
            sw.Write(CShort(101))
            sw.Write(CByte(4))
            sw.Write(CChar("f"))
            sw.Write(CChar("g"))
            sw.Write(CChar("h"))
            sw.Write(CChar("i"))
            sw.Write(CShort(100))
            sw.Write(CByte(4))
            sw.Write(CChar("g"))
            sw.Write(CChar("h"))
            sw.Write(CChar("j"))
            sw.Write(CChar("k"))
            sw.Write(CByte(255))
            sw.Write(CByte(255))  
            sw.Close()
            fs2.Close()

I tried the following but it would only write the "4" as text.  Plus im not sure the syntaxt for CShort in asp.
<%
 'Create an instance of the FSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Create the object and the binary file to write to
Set objBinaryFile = objFSO.CreateTextFile(Server.MapPath("test.etu"))
'Write the information to the file
objBinaryFile.Write (cbyte("4"))
'Close the file
objBinaryFile.Close
'Clean up
Set objFSO = Nothing
%>

0
Comment
Question by:sreichardt
4 Comments
 
LVL 22

Accepted Solution

by:
WMIF earned 500 total points
ID: 17918814
asp's filesystem object doesnt really do binary well.  read this article for options.

http://www.motobit.com/tips/detpg_read-write-binary-files/
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Forcing form refresh - classic ASP 7 72
Select record with the most recent date 14 67
ASP server side get value 15 35
Insert Button on a table 16 36
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question