Hello Guys.
I'm only searching ab out file conversion wth .net. To get a file .txt and transform into a .bin file. Is there a sample with other formats
Thanks by attention.
Hello Guys.
I'm only searching ab out file conversion wth .net. To get a file .txt and transform into a .bin file. Is there a sample with other formats
Thanks by attention.
Do you mean to read the file as txt then write a new file in binary mode
you can read the file with StreamReader and write the new file with BinaryWriter.
Well,
In truly, I'd like to only convert the file (without to read). Because another specific application would read the information about this file content.
Thanks by attention.
Rui
What do you mean by "convert" Will the data in the "bin" file be the same, or does it need to be translated or converted in any way to be "binary"
Hello guys,
Sorry to answer too late.
Weel, I'm trying to explain.
I'm sorry about my english .
For example.
I have a file called "helloworld.txt", which has a line with some information, like a bar code.
And there's a application from a data collector (I don't if there's a model XTM in US) that only read a file in a .BIN format. Because the device only accept applications created by a modified language of BASIC (BASIC not Visual Basic rs), called XPBASIC.
If the .NET offers a option only to convert the content file from .txt to .bin, I'd would find some way, or, find another way (who knows in C++).
Thanks by Attention and sorry about my english.
Could you show us what format this 'helloworld.txt' is in and what is the requirement for .BIN format If the content is the same, you can just use File.Move to rename the file, otherwise it's impossible NOT to read the file, convert it to the desired format, then write the new file out.
Rui Moraes wrote:
Hello guys,
Sorry to answer too late.
Weel, I'm trying to explain.
I'm sorry about my english
.
For example.
I have a file called "helloworld.txt", which has a line with some information, like a bar code.
And there's a application from a data collector (I don't if there's a model XTM in US) that only read a file in a .BIN format. Because the device only accept applications created by a modified language of BASIC (BASIC not Visual Basic rs), called XPBASIC.
If the .NET offers a option only to convert the content file from .txt to .bin, I'd would find some way, or, find another way (who knows in C++).
Thanks by Attention and sorry about my english.
Of Course!!
For example.
This file would have a ID of some Product (only numbers).
Example:
12545687
And this device only prints this information.
Thanks by attention.
Thanks Tony,
When I arrive at home, I'll make some tests with your suggestion.
Thanks.
So the input .txt file contains the ID of some product in TEXT format, what about the format for .BIN file is it a binary number for the same product ID
Rui Moraes wrote:
Of Course!!
For example.
This file would have a ID of some Product (only numbers).
Example:
Code Snippet12545687
And this device only prints this information.
Thanks by attention.
Yes,
It's the .bin file will have the same ID Product content.
The conversion is necessary because the device only reads .bin files
Yes, this way I'm studying.
Hi, Rui
Are you seeking for BitConverter.GetBytes
int i = 1234567;
//Convert to 4 bytes
byte[] data = BitConverter.GetBytes(i);
//Convert it back.
int j = BitConverter.ToInt32(data, 0);
How to write the binary data to the bin file should depend on its format.
Best Regards
Chunsheng Tang