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 and cannot send any file.Here is the code:
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();
I don't know what is the cause of this exception and 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.
Loading
Sam HobbsPosted Oct 8, 2011, 2:29 PM
Note that in articles, the sample code often does not show all the error handling that should be done. I suggest that you put your code in a try block with a catch block. General errors such as WebException are often the result of not handling a previous error.
Also note that the article says nothing about the other end. I assume that if you are sending a file that the other end (your phone?) must be prepared to receive it. Have you looked there? Are you sure that the other end is responding successfully?
Also I see that you are using "obex-push" instead of "obex" as in the article. Are you sure the sample code in the article will also work with "obex-push"?
I know nothing about the OBject EXchange protocol except what I have read after seeing this thread. I am also interested in exploring Bluetooth connectivity. I hope you are able to get this working but unfortunately at the moment I don't have time to play with it.