Reading/Writing Binary Files

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 13
Reputation: Ixeman is an unknown quantity at this point 
Solved Threads: 0
Ixeman Ixeman is offline Offline
Newbie Poster

Reading/Writing Binary Files

 
0
  #1
Sep 13th, 2008
Ok Well, in vb6 it's completely easy.

For an example, im trying to convert this to vb.net but im kinda struggling.

For Example, i don't know what the new get and put statements are in vb.net.
  1. Dim aS As String
  2. Dim aF As String
  3. Open App.Path & "\s.exe" For Binary #1
  4. aS = Space(LOF(1))
  5. Get #1, , aS
  6. Close #1

And in my view of conversion is

  1. Dim aS As String
  2. Dim aF As String
  3. FileOpen(1, "\s.exe", OpenMode.Binary, OpenAccess.ReadWrite)
  4. aS = Space(LOF(1))
  5. FileGet(1, aS)
  6. FileClose(1)

NOTE: THen of course i forgot to add the put statements so the bytes and data would be able to be written into the file. I forgot to add it, and too lazy to add it -.-'. So if anyone knows how i can use the "put" statements in vb.net along with "get" statements.


So if anyone have any information or ideas please share.
Last edited by Ixeman; Sep 13th, 2008 at 2:53 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 148
Reputation: samir_ibrahim is on a distinguished road 
Solved Threads: 16
samir_ibrahim's Avatar
samir_ibrahim samir_ibrahim is offline Offline
Junior Poster

Re: Reading/Writing Binary Files

 
0
  #2
Sep 13th, 2008
  1. Dim swFile As System.IO.StreamWriter
  2. swFile = System.IO.File.CreateText("c:\myfile.txt")
  3. swFile.Write("MyText")
  4. swFile.Close()
  5.  
  6. Dim srFile As System.IO.StreamReader
  7. Dim sTextRead As String
  8. srFile = System.IO.File.OpenText("c:\myfile.txt")
  9. sTextRead = srFile.Read()
  10. Debug.Print(sTextRead)
  11. srFile.Close()

This is not exactly what you want, but it will give you an idea.

ps: if someone see's that there is better code or my code is not correct or lack please point to it because I am still learning

hth
Samir Ibrahim
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 13
Reputation: Ixeman is an unknown quantity at this point 
Solved Threads: 0
Ixeman Ixeman is offline Offline
Newbie Poster

Re: Reading/Writing Binary Files

 
0
  #3
Sep 13th, 2008
Bleh, not exactly what iwas looking for but thanks for your effort!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 13
Reputation: Ixeman is an unknown quantity at this point 
Solved Threads: 0
Ixeman Ixeman is offline Offline
Newbie Poster

Re: Reading/Writing Binary Files

 
0
  #4
Sep 19th, 2008
Bump?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC