Solved

Convert vb.net binary write code to asp

Posted on 2006-11-10
4
1,179 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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