Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert vb.net binary write code to asp

Posted on 2006-11-10
4
Medium Priority
?
1,198 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
1 Comment
 
LVL 22

Accepted Solution

by:
WMIF earned 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

824 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