LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2011, 04:06 AM   #1
ridoy
LQ Newbie
 
Registered: Feb 2011
Posts: 19

Rep: Reputation: 1
Bluetooth file sending problem


I am new in Bluetooth programming.In an application i face a problem during sending file from my computer to my mobile.In my program i first detect enabled bluetooth devices by a search button and then set connections with them by a connect button..it works as well.but when i try to send a file it shows exception which names WebException.
Quote:
public OpenFileDialog ofd;
//string filename = System.IO.Path.GetFileName(ofd.FileName);
String adr = "0025677FB346";
Uri u = new Uri("obex-push://" + adr.ToString() + "/" + fileName);
ObexWebRequest owr = new ObexWebRequest(u);
owr.ReadFile(ofd.FileName);
ObexWebResponse response = (ObexWebResponse)owr.GetResponse(); //Exception shows here
response.Close();
How can i solve this problem?Can you give any idea?or are there any easy way to send file via Bluetooth?Thanks for any suggestion.
 
Old 10-21-2011, 11:56 AM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083
I notice that you've marked this thread as solved. Would you mind updating the thread with your solution, so that other who have the same problem can benefit? Thanks.

--jeremy
 
Old 10-22-2011, 01:08 AM   #3
ridoy
LQ Newbie
 
Registered: Feb 2011
Posts: 19

Original Poster
Rep: Reputation: 1
I faces a lot of problems to solve this.Below is my solution..

Last edited by ridoy; 10-22-2011 at 01:27 AM.
 
Old 10-22-2011, 01:13 AM   #4
ridoy
LQ Newbie
 
Registered: Feb 2011
Posts: 19

Original Poster
Rep: Reputation: 1
Yes,here is my solution:

Quote:
private void buttonSend_Click(object sender, EventArgs e)
{
this.thrSend = new Thread(new ThreadStart(sendfile));
this.thrSend.Start();
}

private void sendfile()
{
SelectBluetoothDeviceDialog dialog = new SelectBluetoothDeviceDialog();
dialog.ShowAuthenticated = true;
dialog.ShowRemembered = true;
dialog.ShowUnknown = true;
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Select File";
ofd.Filter = "Text Document|*.txt|All Files (*.*)|.*";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (ofd.ShowDialog() == DialogResult.OK)
{
Cursor.Current = Cursors.WaitCursor;
System.Uri uri = new Uri("obex://" + dialog.SelectedDevice.ToString() + "/" + ofd.FileName);
ObexWebRequest request = new ObexWebRequest(uri);
request.ReadFile(ofd.FileName);
ObexWebResponse response = (ObexWebResponse)request.GetResponse();
MessageBox.Show(response.StatusCode.ToString());
response.Close();
Cursor.Current = Cursors.Default;
}
else
{
MessageBox.Show("File Not Selected");
}
}
else
{
MessageBox.Show("Device Not Selected");
}


}
 
Old 10-22-2011, 10:29 AM   #5
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,602

Rep: Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083Reputation: 4083
Thanks for the update.

--jeremy
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bluetooth file transfer problem (nokia 6600) abourke Linux - Newbie 2 11-08-2009 01:06 PM
Sending files from Motorola v360 cellphone to hard drive using Bluetooth ixhabbaba Linux - Software 2 08-30-2008 01:49 AM
bluetooth...mobile connectivity...file transfer problem vineet7kumar Linux - Newbie 1 09-06-2007 08:48 AM
Bluetooth File Transfer Problem gbowden Slackware 0 12-27-2006 05:00 PM
Sending File Via Bluetooth kitying Linux - Wireless Networking 4 02-17-2006 01:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration