|
-
Oct 3rd, 2002, 07:22 PM
#1
Thread Starter
Hyperactive Member
Open as Binary , gr !
i'm stuck on this since a few days
i need the translation from VB6 to VB.NET
Code:
Open FileName For Binary As #1
Get #1, CurrentPOS, strData
Close #1
i tried with the IO class and FileOpen but, never worked!
thanks
-
Oct 3rd, 2002, 08:01 PM
#2
Try something like this:
VB Code:
Dim fs As IO.FileStream = New IO.FileStream(filename, IO.FileMode.Open)'open file
Dim br As New IO.BinaryReader(fs)'read as binary
Dim b() As Byte = br.ReadBytes(fs.Length)'now the contents are in a byte array
Dim str As String = System.Text.Encoding.ASCII.GetString(b)'convert byte array to string
br.Close()'close file
fs.Close()
-
Oct 3rd, 2002, 09:18 PM
#3
Fanatic Member
or to go the old way in .net it is
VB Code:
Dim intFile as integer = FreeFile
FileOpen(intFile, "C:\bob.txt", OpenMode.Binary, OpenAccess.Read)
FileClose(intFile)
-
Oct 4th, 2002, 07:22 AM
#4
Thread Starter
Hyperactive Member
Originally posted by rudvs2
or to go the old way in .net it is
VB Code:
Dim intFile as integer = FreeFile
FileOpen(intFile, "C:\bob.txt", OpenMode.Binary, OpenAccess.Read)
FileClose(intFile)
Rudvs2 > yea i tried that but, how can i use the "GET #1, FilePosition, strData". I didnt figure it out...
Edneeis > Thanks, i'll try to work it out tonite.
thanks alot guys. ;p
-
Oct 4th, 2002, 08:25 PM
#5
Addicted Member
The get statement has changed to fileget
FileOpen(1, "C:\TESTFILE.txt", OpenMode.Binary)
FileGet(FileNumber, Data,RecordNumber)
Jeremy
-
Oct 5th, 2002, 09:51 AM
#6
Thread Starter
Hyperactive Member
ataboy Jeremy...
thanks alot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|