Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Seeking a simple program ~ text to binary converter
 

Seeking a simple program ~ text to binary converter

Hi all

Wonder if anyone can help me out here.

I’m looking for a simple program that would covert a string of 48 x 0’s and 1’s in text format and write them to a simple 6 byte binary file.

It would need to run on windows XP in the background (dos mode?).

The input string and saving file name would need to be input via switches, ideally something like:

Program.exe /B 000000100000000000000000000000000000010000001001 /F C:\Myfile.bin

I’ve searched the net for hours but not come up with anything...anyone one know of anything like that?

Thanks

Phil

Hawksey  Friday, February 22, 2008 10:08 AM

Hi, Hawksey

What your want is Windows Console Application other than Windows Forms Application, you can retrieve the arguments in the main() method, and convert the text into a binary fileby using the BinaryWriter class, something like this

Code Snippet

Program

{

static void Main(string[] args)

{

string op1 = args[0];

string text = args[1];

string op2 = args[2];

string path = args[3];

switch (op1.ToLower())

{

case "/b":

using (BinaryWriter binWriter =

new BinaryWriter(File.Open(path, FileMode.Create)))

{

binWriter.Write(text);

}

break;

// other cases

}

}

}

Zhi-Xin Ye  Wednesday, February 27, 2008 12:41 PM

Hi, Hawksey

What your want is Windows Console Application other than Windows Forms Application, you can retrieve the arguments in the main() method, and convert the text into a binary fileby using the BinaryWriter class, something like this

Code Snippet

Program

{

static void Main(string[] args)

{

string op1 = args[0];

string text = args[1];

string op2 = args[2];

string path = args[3];

switch (op1.ToLower())

{

case "/b":

using (BinaryWriter binWriter =

new BinaryWriter(File.Open(path, FileMode.Create)))

{

binWriter.Write(text);

}

break;

// other cases

}

}

}

Zhi-Xin Ye  Wednesday, February 27, 2008 12:41 PM

You can use google to search for other answers

Custom Search

More Threads

• Can not load my creature.
• Class is not in the assembly
• Conflict resolution does nothing
• .NET Terrarium 1.0.25.300 Available
• Movie Collection Kit - Need Help
• bowwow10 - how does he do it?
• caching FormsAuthenticationTicket
• What's going on with Terrarium?
• Excel 2002 problem
• Public Terrarium Server?