sreichardt
asked on
Convert vb.net binary write code to asp
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.Defau lt)
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("Scrip ting.FileS ystemObjec t")
'Create the object and the binary file to write to
Set objBinaryFile = objFSO.CreateTextFile(Serv er.MapPath ("test.etu "))
'Write the information to the file
objBinaryFile.Write (cbyte("4"))
'Close the file
objBinaryFile.Close
'Clean up
Set objFSO = Nothing
%>
Dim fs2 As New FileStream("c:\test.etu", FileMode.Create, FileAccess.Write)
Dim sw As New BinaryWriter(fs2, System.Text.Encoding.Defau
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("Scrip
'Create the object and the binary file to write to
Set objBinaryFile = objFSO.CreateTextFile(Serv
'Write the information to the file
objBinaryFile.Write (cbyte("4"))
'Close the file
objBinaryFile.Close
'Clean up
Set objFSO = Nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.