Solved

Convert vb.net binary write code to asp

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now