pcuser_tom Posted May 24, 2007 Share Posted May 24, 2007 (edited) I'm trying to convert this simple vb6 code to ASP but I just can't figure out how to do it. Open File1 For Binary As 1 Open File2 For Binary As 2 For i = 1 To LOF(1) Get #1, , mybyte ' Manipulate mybyte here Put #2, , mybyte Next Close 2Close 1How do I read/write a binary file in ASP?Tom Edited May 24, 2007 by pcuser_tom Link to comment Share on other sites More sharing options...
jcarle Posted May 24, 2007 Share Posted May 24, 2007 (edited) <% Dim ReadStream Dim WriteStream Dim byteBuffer Const adTypeBinary = 1 Const adSaveCreateOverWrite = 2 Set ReadStream = Server.CreateObject("ADODB.Stream") ReadStream.Type = adTypeBinary ReadStream.Open ReadStream.LoadFromFile "infile.ext" Set WriteStream = CreateObject("ADODB.Stream") WriteStream.Type = adTypeBinary WriteStream.Open While Not ReadStream.EOS byteBuffer = ReadStream.Read(1) WriteStream.Write byteBuffer WEnd WriteStream.SaveToFile "outfile.ext", adSaveCreateOverWrite WriteStream.Close Set WriteStream = Nothing ReadStream.Close Set ReadStream = Nothing%>I suggest that you look up DevGuru in the future for further reference. Edited May 24, 2007 by jcarle Link to comment Share on other sites More sharing options...
pcuser_tom Posted June 9, 2007 Author Share Posted June 9, 2007 Thank you jcarle Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now