Bluetooth no WIndows CE 5.0 com C#
01/08/2011
0
Olá pessoal. Estou desenvolvento uma aplicação em C# para um Coletor de Dados com Windows CE 5.0, e estou precisando de uma rotina em para tranferir arquivo via Bluetooth. Eu consegui uma rotina onde eu consigo enviar um arquivo para uma impressora bluetooth mas quando eu tento transferir um arquivo da errO. Se alguém conhecer alguma e poder me passar ficarei muito grato.
Segue o código que eu estou usando:
Segue o código que eu estou usando:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using InTheHand.Net.Sockets; using InTheHand.Net.Bluetooth; using System.IO; using InTheHand.Net; using WinCE.entidades; namespace WinCE.Utils { public partial class Imprimir : Form { private Guid service = BluetoothService.SerialPort; private BluetoothClient bluetoothClient; public Imprimir() { InitializeComponent(); //buscaDevice(); } private void btnBuscar_Click(object sender, EventArgs e) { buscaDevice(); } private void buscaDevice() { lbMsg.Text = "Searching devices..."; //BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable; bluetoothClient = new BluetoothClient(); Cursor.Current = Cursors.WaitCursor; BluetoothDeviceInfo[] bluetoothDeviceInfo = { }; bluetoothDeviceInfo = bluetoothClient.DiscoverDevices(10); listDevice.DataSource = bluetoothDeviceInfo; listDevice.DisplayMember = "DeviceName"; listDevice.ValueMember = "DeviceAddress"; listDevice.Focus(); Cursor.Current = Cursors.Default; lbMsg.Text = "Impressoras Encontradas:"; } private void btnPrint_Click(object sender, EventArgs e) { if ( listDevice.SelectedValue != null ) { try { bluetoothClient.Connect(new BluetoothEndPoint((BluetoothAddress)listDevice.SelectedValue, service)); imprimir(); //MessageBox.Show("Connected to " + listDevice.SelectedValue.ToString(), "Info"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro"); } } } private void imprimir() { lbMsg.Text = "Enviando para Impressora..."; try { StreamWriter strSend = new StreamWriter( bluetoothClient.GetStream(), new System.Text.UTF8Encoding()); string dtaRead = GeraSaida.FormatSaidaString(Dados.movLista); strSend.WriteLine( dtaRead+"\n\n\n"); strSend.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro"); } this.Close(); } private void lbMsg_ParentChanged(object sender, EventArgs e) { } } }
Kleberton
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)