File transfer via serial port

I am trying to send files via the comm port. I am able to do so w/ text files, however, i am not able to send executable files. When i tell my program to send an exe file from one computer to another it will copy the file from the first computer to the second but if i open it w/ a hex editor, it will not look anything like the orig. file.

Comments

: Hey,: : I am trying to send files via the comm port. I am able to do so w/ text files, however, i am not able to send executable files. When i tell my program to send an exe file from one computer to another it will copy the file from the first computer to the second but if i open it w/ a hex editor, it will not look anything like the orig. file.: : Do you know of a way to copy an exe file via the comm port?: : thanks!:

What control (Maybe even API) are you using??? Maybe you send it as text, while you should actually send the file as a piece of binary data!

[b][red]This message was edited by rickrat at 2003-8-14 7:52:21[/red][/b][hr][b][red]This message was edited by rickrat at 2003-8-14 7:51:24[/red][/b][hr]: : Hey,: : : : I am trying to send files via the comm port. I am able to do so w/ text files, however, i am not able to send executable files. When i tell my program to send an exe file from one computer to another it will copy the file from the first computer to the second but if i open it w/ a hex editor, it will not look anything like the orig. file.: : : : Do you know of a way to copy an exe file via the comm port?: : : : thanks!: : : : What control (Maybe even API) are you using??? Maybe you send it as text, while you should actually send the file as a piece of binary data!: : Greets...: Richard: : I'm using the MSComm control, i know i have to open the exe file in binary, at least i think i have to, but i am not quite sure as to how to do that. I think one of the problems that i am getting is that when i open the code on the first computer before it is sent over, it is not opening correctly.Right now i am using this code just to open the program:

Also, one thing that you could do as a good example:1. Make an executable file that just simply display's a message box to the user and then ends.2. Take that file and change it from *.exe to *.txt and open it w/ notepad3. copy the contents of the file to another *.txt file and rename the new *.txt file as a *.exe file4. you will notice that the program will not run, but will be in the form as a dos prompt, or command prompt

if i can find a way to copy the contents from one exe file to another i think that will be the answer that i am looking for.

: [b][red]This message was edited by rickrat at 2003-8-14 7:52:21[/red][/b][hr]: [b][red]This message was edited by rickrat at 2003-8-14 7:51:24[/red][/b][hr]: : : Hey,: : : : : : I am trying to send files via the comm port. I am able to do so w/ text files, however, i am not able to send executable files. When i tell my program to send an exe file from one computer to another it will copy the file from the first computer to the second but if i open it w/ a hex editor, it will not look anything like the orig. file.: : : : : : Do you know of a way to copy an exe file via the comm port?: : : : : : thanks!: : : : : : : What control (Maybe even API) are you using??? Maybe you send it as text, while you should actually send the file as a piece of binary data!: : : : Greets...: : Richard: : : : : I'm using the MSComm control, i know i have to open the exe file in binary, at least i think i have to, but i am not quite sure as to how to do that. I think one of the problems that i am getting is that when i open the code on the first computer before it is sent over, it is not opening correctly.: Right now i am using this code just to open the program:: : : Dim intCounter As Integer, intFile As Integer, Char$: intFile = FreeFile(): Open "C:hi.exe" For Binary As intFile: For intCounter = 1 To LOF(intFile): Char$ = Input$(1, #intFile): txtInput.Text = txtInput.Text & Char$: Next: Close intFile: : Any idea's?: : Also, one thing that you could do as a good example:: 1. Make an executable file that just simply display's a message box to the user and then ends.: 2. Take that file and change it from *.exe to *.txt and open it w/ notepad: 3. copy the contents of the file to another *.txt file and rename the new *.txt file as a *.exe file: 4. you will notice that the program will not run, but will be in the form as a dos prompt, or command prompt: : if i can find a way to copy the contents from one exe file to another i think that will be the answer that i am looking for.: : : :

That's because EXE files have alot of character 0's in them. A character 0 in a string indicates the end of that string! That can cause confusing situations. You have to open the file in a different way.

Use:[code]Dim intCounter As Integer, intFile As IntegerDim bytData() As Byte

hi... BitByBit_Thorcan i have your source code?? I am trying to send a text file using mscommm control... But i do not know how to do it.... For example: I have a file called ID.txt in c: , how do i send ID.txt through the serial port using mscomm control? Can ya show me a sample code? I need to complete a school project urgently, the submission is in 2 days time. Can u teach me or tell me how to do it???Can ya email me with the source code to [email protected] ?Thank you very much, hope u will reply me soon....

: hi... BitByBit_Thor: can i have your source code?? : I am trying to send a text file using mscommm control... But i do not know how to do it.... For example: I have a file called ID.txt in c: , how do i send ID.txt through the serial port using mscomm control? Can ya show me a sample code? I need to complete a school project urgently, the submission is in 2 days time. Can u teach me or tell me how to do it???: Can ya email me with the source code to [email protected] ?: Thank you very much, hope u will reply me soon....:

I send you an e-mail. I forgot to add this question: Do you know how to read the file and place the data into a string?

Hi... BitByBit_Thorim working on data tranfer using comm port, and im not able to send file or receive it using comm port to another computer. its a little project in my university, i want u please send to me by e-mail the source of ur work, i need it quickly within these two days, and im very thankful.

: That's because EXE files have alot of character 0's in them. A character 0 in a string indicates the end of that string! That can cause confusing situations. You have to open the file in a different way.:

And because Input generally destroys the data in a file. In text files, you don't notice because it fixes the data by the time you get it. Chr$(0) and either vbCr or vbLf (I forget which of the two) are all reinterpreted as vbCrLf.

And the [b]Len("C:hi.exe")[/b] should have been [b]LOF(intFile)[/b] or [b]FileLen("C:hi.exe")[/b].

: Now bytData() contains the entire file. Now I don't know the Comm Control, so I don't know how you have to send it over, but now you can just loop trough the array and send each byte individually!:

I think MSComm will accept either a string or a byte array, because VB will often allow you to substitute one for the other. If it does allow the byte array, I would suggest using it instead of a string as it should be read faster (VB does an internal conversion on strings to unicode).