469,963 Members | 1,885 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

Convert string to hex and write file


What I am trying to accomplish is to initiate remote desktop session from
within my C# application to XP Pro machine NOT terminal services to a

I have not found any way to do this with code (if you know of a way then I
would love to hear about it). What I have created so far is;

1. Write RDP file to the HD from the code
2. Start process with file as argument

Process rdp = new Process();
rdp.StartInfo.FileName = "mstsc.exe"; //remote desktop
rdp.StartInfo.WorkingDirectory = WorkingDirectory; //dir of rdp file
rdp.StartInfo.Arguments = Arguments; //rdp file

This works however I want to save the username and password so that it just
logs the user in automatically.
If you look at an RDP file in notepad you will see that it is all text. If
right click and choose edit you can input a password and click save
password. If you save your changes you get a long binary hash password.

If you open it in notepad and copy everything and paste it into an empty
text file and rename it RDP, you would think you have the same thing. Not
so. Original is 5k, copied version is 3k. There is in fact a whole bunch of
hidden characters. If you open the original in a hex editor then you will
see that the whole file is prepended by ff fe and there is 00 in between
every character.

This is what makes up the extra 2k.So my question is; how do I parse each
line of text (comes from DB), convert it to HEX, insert the 00 value
(whatever that is) and then write it out as a file with a .rdp extension?

I would appreciate any help. Right now I am using
FileStream file = new FileStream(WorkingDirectory + "\\" + Arguments,
StreamWriter sw = new StreamWriter(file);
to write the file. Can I use the same thing to write HEX?


Jan 28 '06 #1
1 10204
IIRC the 00 between each character in the hex view shows that the
orginal file is Unicode. When you save the file in notepad it defaults
to ANSI.

Jan 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by David Lawson | last post: by
17 posts views Thread by David Scemama | last post: by
12 posts views Thread by Brian Henry | last post: by
3 posts views Thread by GM | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.