G
Guest
Hi
I'm trying to copy a text file from one handheld to another handheld, they are both iPAQ h2210's, via IR. I found an example of how to do this on the net and almost have it working. I can receive the stream over IR but I can't seem to write it to a file. Here is my code to receive and write it to a file
===================================================================
'set up file to write t
Dim outputStream As IO.Strea
outputStream = System.IO.File.Open("test.txt", IO.FileMode.Create
'create listener and start i
m_irListener = New Net.Sockets.IrDAListener(IRDA_SERVICE_NAME
m_irListener.Start(
'accept the I
Dim irdaClient As Net.Sockets.IrDAClien
irdaClient = m_irListener.AcceptIrDAClient(
'create in Strea
Dim irStreamIn As System.IO.Strea
irStreamIn = irdaClient.GetStrea
Const BUFFER_SIZE = 102
Dim inBuffer(BUFFER_SIZE) As Byt
Dim bytesRead As Intege
D
'Read the bytes in from the IR por
bytesRead = irStreamIn.Read(inBuffer, 0, BUFFER_SIZE
'Write the bytes out to our output strea
If (bytesRead > 0) The
outputStream.Write(inBuffer, 0, bytesRead
End I
Loop While (bytesRead > 0
outputStream.Flush() 'Finish writing any outpu
'Close our input strea
irStreamIn.Close(
'Close the irda clien
irdaClient.Close(
'Close the listener if its runnin
StopListenerIfRunning(
'Close the file we have been writing t
outputStream.Close(
=================================================================
my file 'test.txt' is zero length and nothing is written to it
But if I put the following code
========================================
Dim i As Intege
While i < 10
MessageBox.Show(Chr(inBuffer(i)).ToString
i +=
End Whil
=========================================
right after the do/while loop, I get my characters one at a time in the messagebox...so I know the files contents are getting sent over the IR stream, but I can't seem to get it to write out to a file. Does the size of the file I'm sending matter? It's about 7500 bytes
If anyone can help it would be much appreciated
Thanks
skicow
I'm trying to copy a text file from one handheld to another handheld, they are both iPAQ h2210's, via IR. I found an example of how to do this on the net and almost have it working. I can receive the stream over IR but I can't seem to write it to a file. Here is my code to receive and write it to a file
===================================================================
'set up file to write t
Dim outputStream As IO.Strea
outputStream = System.IO.File.Open("test.txt", IO.FileMode.Create
'create listener and start i
m_irListener = New Net.Sockets.IrDAListener(IRDA_SERVICE_NAME
m_irListener.Start(
'accept the I
Dim irdaClient As Net.Sockets.IrDAClien
irdaClient = m_irListener.AcceptIrDAClient(
'create in Strea
Dim irStreamIn As System.IO.Strea
irStreamIn = irdaClient.GetStrea
Const BUFFER_SIZE = 102
Dim inBuffer(BUFFER_SIZE) As Byt
Dim bytesRead As Intege
D
'Read the bytes in from the IR por
bytesRead = irStreamIn.Read(inBuffer, 0, BUFFER_SIZE
'Write the bytes out to our output strea
If (bytesRead > 0) The
outputStream.Write(inBuffer, 0, bytesRead
End I
Loop While (bytesRead > 0
outputStream.Flush() 'Finish writing any outpu
'Close our input strea
irStreamIn.Close(
'Close the irda clien
irdaClient.Close(
'Close the listener if its runnin
StopListenerIfRunning(
'Close the file we have been writing t
outputStream.Close(
=================================================================
my file 'test.txt' is zero length and nothing is written to it
But if I put the following code
========================================
Dim i As Intege
While i < 10
MessageBox.Show(Chr(inBuffer(i)).ToString
i +=
End Whil
=========================================
right after the do/while loop, I get my characters one at a time in the messagebox...so I know the files contents are getting sent over the IR stream, but I can't seem to get it to write out to a file. Does the size of the file I'm sending matter? It's about 7500 bytes
If anyone can help it would be much appreciated
Thanks
skicow