Fordraiders
asked on
Create binary file from text file
vb.net8
I have a text file..
Pipe delimited format
material_no|alt_material_n o_Green
4TM77|4YM42
5E103|5E104
5E081|5E080
2F141|4ZF10
4KK81|4KK82
2F145|2F132
3UM46|4KK77
5A283|4KK77
3W230|4XM33
3W231|4XM35
4W174|4XM37
4W075|4XM39
4W076|4XM43
6W693|4XM57
6W694|4XM59
6W695|4XM61
5E145|5E077
Is there a way to create a binary file from this text format ?
Thanks
fordraiders
I have a text file..
Pipe delimited format
material_no|alt_material_n
4TM77|4YM42
5E103|5E104
5E081|5E080
2F141|4ZF10
4KK81|4KK82
2F145|2F132
3UM46|4KK77
5A283|4KK77
3W230|4XM33
3W231|4XM35
4W174|4XM37
4W075|4XM39
4W076|4XM43
6W693|4XM57
6W694|4XM59
6W695|4XM61
5E145|5E077
Is there a way to create a binary file from this text format ?
Thanks
fordraiders
1)Use IO.File.ReadAllText method to read text file
2) Use GetBytes method to convert text to byte array
3) Use WriteAllBytes to write binary file
File.WriteAllBytes("Binary File.bin", Encoding.Ascii.GetBytes(Fi le.ReadAll Text("Text File.txt") )
2) Use GetBytes method to convert text to byte array
3) Use WriteAllBytes to write binary file
File.WriteAllBytes("Binary
ASKER
does it matter how big the text file is ?
ASKER
its that one line of code ?
ASKER
declarations for :
File.WriteAllBytes("Binary File.bin", Encoding.Ascii.GetBytes(Fi le.ReadAll Text("Text File.txt") )
??
File.WriteAllBytes("Binary
??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
keeps telling me invalid outside procedure.
references ? maybe
I have tagged "vb scripting runtime"
references ? maybe
I have tagged "vb scripting runtime"
>keeps telling me invalid outside procedure.
I hoped you would add it behind a button or something.
I hoped you would add it behind a button or something.
ASKER
Calling this from a button:
BinaryTransfer()
Imports System.IO
Imports System.Text
Option Explicit
Sub BinaryTransfer()
File.WriteAllBytes ("C:\Program Files\Crs\Keep.bin"), Encoding.Ascii.GetBytes(Fi le.ReadAll Text("C:\P rogram Files\Crs\keep.txt"))
End Sub
BinaryTransfer()
Imports System.IO
Imports System.Text
Option Explicit
Sub BinaryTransfer()
File.WriteAllBytes ("C:\Program Files\Crs\Keep.bin"), Encoding.Ascii.GetBytes(Fi
End Sub
Can you show the whole code? And what the error is now?
ASKER
You added this question in VB.NET zone so the code I have provided is for vb.net.
ASKER
i did not add it the moderator did...
sorry
sorry
ASKER
oop sorry...
in my vba mode...
Thnks
in my vba mode...
Thnks
ASKER
Thanks
so one way is to create a COM visible DLL in C# or VB.NET , then call it from Visual Basic
(I am assuming you are not using VB.NET)